# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
885845 | 2023-12-10T21:14:18 Z | JakobZorz | 정렬하기 (IOI15_sorting) | C++17 | 4 ms | 604 KB |
#include"sorting.h" #include<iostream> #include<vector> using namespace std; int n; int*x,*y,*s; vector<pair<int,int>>construct(int m){ vector<pair<int,int>>ans(m); vector<int>perm(n),curr(n); for(int i=0;i<n;i++){ perm[i]=i; curr[i]=s[i]; } for(int i=0;i<m;i++) swap(curr[x[i]],curr[y[i]]); for(int i=m-1;i>=0;i--) swap(perm[x[i]],perm[y[i]]); for(int i=0;i<m;i++){ swap(perm[x[i]],perm[y[i]]); for(int j=0;j<n;j++){ if(curr[j]!=j){ ans[i].first=perm[j]; for(int k=0;k<n;k++){ if(curr[k]==j){ swap(curr[j],curr[k]); ans[i].second=perm[k]; break; } } break; } } } return ans; } int findSwapPairs(int N,int S[],int _,int X[],int Y[],int P[],int Q[]){ n=N; x=X; y=Y; s=S; vector<pair<int,int>>res=construct(n); for(int i=0;i<n;i++){ P[i]=res[i].first; Q[i]=res[i].second; } vector<int>test(n); for(int i=0;i<n;i++) test[i]=s[i]; for(int i=0;i<n;i++){ swap(test[x[i]],test[y[i]]); swap(test[P[i]],test[Q[i]]); bool sorted=true; for(int j=0;j<n;j++) if(test[j]!=j) sorted=false; if(sorted) return i+1; } //for(int i:test) //cout<<i<<" "; //cout<<"\n"; return n; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 600 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 600 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 600 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 600 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 600 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 416 KB | Output is correct |
21 | Incorrect | 1 ms | 604 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |