# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
515609 | 2022-01-19T10:35:20 Z | Theo830 | Cat (info1cup19_cat) | C++17 | 765 ms | 5392 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training int main(void){ ll t; cin>>t; while(t--){ ll n; cin>>n; ll arr[n]; vll a[2]; ll posa = 0; vll b; f(i,0,n){ cin>>arr[i]; if(i < n/2 && arr[i] > n/2){ posa++; b.pb(n + 1 - arr[i]); } arr[i] = min(arr[i],n + 1 - arr[i]); a[i >= n/2].pb(arr[i]); } reverse(all(a[1])); ll res = 0; f(i,0,a[0].size()){ if(a[0][i] != i+1){ res++; } } if(a[0] == a[1] && (posa % 2 == 0)){ cout<<res / 2<<" "; cout<<"0\n"; } else{ cout<<"-1\n"; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 208 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 300 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 208 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 42 ms | 300 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 14 ms | 304 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 12 ms | 204 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 300 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 705 ms | 2344 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 695 ms | 3416 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 670 ms | 4080 KB | Correctly distinguished between possibility and impossibility |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 208 KB | Correctly distinguished between possibility and impossibility |
2 | Correct | 42 ms | 300 KB | Correctly distinguished between possibility and impossibility |
3 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
4 | Correct | 35 ms | 204 KB | Correctly distinguished between possibility and impossibility |
5 | Correct | 14 ms | 304 KB | Correctly distinguished between possibility and impossibility |
6 | Correct | 12 ms | 204 KB | Correctly distinguished between possibility and impossibility |
7 | Correct | 705 ms | 2344 KB | Correctly distinguished between possibility and impossibility |
8 | Correct | 695 ms | 3416 KB | Correctly distinguished between possibility and impossibility |
9 | Correct | 670 ms | 4080 KB | Correctly distinguished between possibility and impossibility |
10 | Correct | 669 ms | 1332 KB | Correctly distinguished between possibility and impossibility |
11 | Correct | 714 ms | 1608 KB | Correctly distinguished between possibility and impossibility |
12 | Correct | 708 ms | 5180 KB | Correctly distinguished between possibility and impossibility |
13 | Correct | 765 ms | 5212 KB | Correctly distinguished between possibility and impossibility |
14 | Correct | 733 ms | 5392 KB | Correctly distinguished between possibility and impossibility |