답안 #861287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861287 2023-10-15T19:40:47 Z Mizo_Compiler Cat (info1cup19_cat) C++14
40 / 100
320 ms 12880 KB
#include <bits/stdc++.h>
 
using namespace std;
vector<pair<int,int>> con;
bool vis[200001];int arr[200001];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int t;cin>>t;
    z:while(t--){
        int n;cin>>n;
        for(int i = 1;i<=n;i++)vis[i] = 0;
        con.clear();
        int pos[n+1];
        for(int i = 1;i<=n;i++){
            cin>>arr[i];pos[arr[i]] = i;
        }
        int g = 0;int lol = 0;
        for(int i = 1;i<=n/2;i++){
            if(arr[i]!=i)g++;
            if(n-arr[i]+1!=arr[n-i+1]){
                cout<<-1<<endl;
                goto z;
            }if(arr[i]>n/2){
                lol++;
            }
        }
        if(lol&1){
            cout<<-1<<endl;
            goto z;
        }
        for(int i = 1;i<=n;i++){
            while(pos[i]!=i&&pos[i]!=n-i+1) {
                int tmp=pos[i];
                con.push_back({i,tmp});
                swap(pos[i],pos[tmp]);
                swap(pos[n-i+1],pos[n-tmp+1]);
            }
        }
      	for (int i = 1; i <= n/2; i++) {
          	if (pos[i] != i)con.push_back({i, n-i+1});
        }
        cout<<con.size()<<" "<<con.size()<<"\n";
        for(auto i:con)cout<<i.first<<" "<<i.second<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct number of moves
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 604 KB Correct number of moves
2 Correct 14 ms 500 KB Correct number of moves
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct number of moves
2 Correct 14 ms 604 KB Correct number of moves
3 Correct 14 ms 500 KB Correct number of moves
4 Correct 15 ms 600 KB Correct number of moves
5 Correct 7 ms 860 KB Correct number of moves
6 Correct 5 ms 344 KB Correct number of moves
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 604 KB Correct number of moves
2 Correct 14 ms 500 KB Correct number of moves
3 Correct 294 ms 10448 KB Correct number of moves
4 Correct 276 ms 10136 KB Correct number of moves
5 Correct 320 ms 12496 KB Correct number of moves
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct number of moves
2 Correct 14 ms 604 KB Correct number of moves
3 Correct 14 ms 500 KB Correct number of moves
4 Correct 15 ms 600 KB Correct number of moves
5 Correct 7 ms 860 KB Correct number of moves
6 Correct 5 ms 344 KB Correct number of moves
7 Correct 294 ms 10448 KB Correct number of moves
8 Correct 276 ms 10136 KB Correct number of moves
9 Correct 320 ms 12496 KB Correct number of moves
10 Correct 318 ms 9748 KB Correct number of moves
11 Correct 260 ms 8152 KB Correct number of moves
12 Correct 290 ms 11816 KB Correct number of moves
13 Correct 304 ms 12880 KB Correct number of moves
14 Correct 284 ms 10932 KB Correct number of moves