# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
861289 | 2023-10-15T19:46:08 Z | Ahmed57 | Cat (info1cup19_cat) | C++17 | 686 ms | 38868 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 it = 0;it<30;it++){ for(int i = 1;i<=n;i++){ if(arr[i]!=i){ con.push_back({arr[i],i}); int tmp = arr[n-i+1]; swap(arr[i],arr[arr[i]]); swap(arr[n-i+1],arr[tmp]); } } } cout<<con.size()<<" "<<con.size()<<"\n"; for(auto i:con)cout<<i.first<<" "<<i.second<<"\n"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 856 KB | Correctly distinguished between possibility and impossibility |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 604 KB | Output is correct |
2 | Correct | 17 ms | 604 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 856 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 18 ms | 604 KB | Output is correct |
3 | Correct | 17 ms | 604 KB | Output is correct |
4 | Correct | 103 ms | 4648 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 32 ms | 1868 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 30 ms | 1624 KB | Correctly distinguished between possibility and impossibility |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 604 KB | Output is correct |
2 | Correct | 17 ms | 604 KB | Output is correct |
3 | Correct | 341 ms | 13524 KB | Output is correct |
4 | Correct | 323 ms | 12264 KB | Output is correct |
5 | Correct | 365 ms | 15340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 856 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 18 ms | 604 KB | Output is correct |
3 | Correct | 17 ms | 604 KB | Output is correct |
4 | Correct | 103 ms | 4648 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 32 ms | 1868 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 30 ms | 1624 KB | Correctly distinguished between possibility and impossibility |
7 | Correct | 341 ms | 13524 KB | Output is correct |
8 | Correct | 323 ms | 12264 KB | Output is correct |
9 | Correct | 365 ms | 15340 KB | Output is correct |
10 | Incorrect | 686 ms | 38868 KB | Number of operations limit exceeded |
11 | Halted | 0 ms | 0 KB | - |