# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782530 | 2023-07-14T04:21:47 Z | Lyrically | Sorting (IOI15_sorting) | C++17 | 16 ms | 464 KB |
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define pb push_back #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) int read(){int x;scanf("%d",&x);return x;} void print(int x){printf("%d\n",x);} void file(string s) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int mod=998244353; int r[200005]; int fa[200005]; bool vis[200005]; int findSwapPairs(int n,int s[],int m,int x[],int y[],int p[],int q[]) { rep(j,m){p[j]=q[j]=0;} if(is_sorted(s,s+n)){return 0;} rep(i,m) { swap(s[x[i]],s[y[i]]); rep(j,n) { //cout<<s[j]<<" "; r[j]=s[j]; fa[s[j]]=j;vis[j]=0; } //cout<<endl; int inv=n; int cur=0; bool fl=1; rep(j,n) { if(!vis[j]) { inv--; //cout<<i<<" "<<j<<endl; int now=j; while(!vis[now]) { vis[now]=1; if(cur==m){fl=0;break;} if(vis[fa[now]]){break;} //cout<<now<<" "<<fa[now]<<endl; p[cur]=now,q[cur]=fa[now]; cur++; now=fa[now]; } if(!fl){break;} } } rep(j,n){s[j]=r[j];} if(fl&&inv<=i+1) { return i+1; } rep(j,m){p[j]=q[j]=0;} } return -1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Incorrect | 0 ms | 312 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 312 KB | Output is correct |
14 | Incorrect | 0 ms | 312 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 464 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 464 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |