0分求助,样例和讨论区hack都可以过

P1188 PASTE

asd890123 @ 2025-01-10 17:34:04

rt,实在调不出来了

#include<bits/stdc++.h>
int txt[100005],cpy[100005];
int main(){
    std::cin.tie(0)->sync_with_stdio(0);
    int n,k;
    std::cin >> n >> k;
    for (int i = 1;i <= n;i++) txt[i] = i;
    while (k--){
        int A,B,C;
        std::cin >> A >> B >> C;
        for (int i = A;i <= B;i++) cpy[i - A + 1] = txt[i];
        for (int i = B + 1;i <= n;i++) txt[i - B - 1 + A] = txt[i];
        for (int i = C + 1;i <= C + 1 + B - A;i++) txt[i + B - A + 1] = txt[i];
        for (int i = C + 1;i <= C + 1 + B - A;i++) txt[i] = cpy[i - C];
    }
    for (int i = 1;i <= 10;i++) std::cout << txt[i] << '\n';
    return 0;
}

RE on #2 #8 #9 #10,剩下都是WA


|