# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
861278 | 2023-10-15T19:11:11 Z | Ahmed57 | Cat (info1cup19_cat) | C++17 | 173 ms | 2312 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/2;i++){ if(!vis[i]){ /*int st = i; vis[i] = 1; int e = arr[i]; while(vis[e]==0){ vis[e] = 1; con.push_back({e,i}); e = arr[e]; }*/ } } cout<<con.size()<<" "<<con.size()<<endl; for(auto i:con)cout<<i.first<<" "<<i.second<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 348 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 348 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 12 ms | 348 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 5 ms | 344 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 5 ms | 344 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 160 ms | 1116 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 161 ms | 1620 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 161 ms | 1884 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 348 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 13 ms | 348 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 12 ms | 348 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 5 ms | 344 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 5 ms | 344 KB | Correctly distinguished between possibility and impossibility |
7 | Correct | 160 ms | 1116 KB | Correctly distinguished between possibility and impossibility |
8 | Correct | 161 ms | 1620 KB | Correctly distinguished between possibility and impossibility |
9 | Correct | 161 ms | 1884 KB | Correctly distinguished between possibility and impossibility |
10 | Correct | 164 ms | 812 KB | Correctly distinguished between possibility and impossibility |
11 | Correct | 162 ms | 856 KB | Correctly distinguished between possibility and impossibility |
12 | Correct | 167 ms | 2188 KB | Correctly distinguished between possibility and impossibility |
13 | Correct | 173 ms | 2312 KB | Correctly distinguished between possibility and impossibility |
14 | Correct | 164 ms | 2128 KB | Correctly distinguished between possibility and impossibility |