# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60141 | 2018-07-23T17:46:19 Z | dukati8 | 정렬하기 (IOI15_sorting) | C++14 | 1000 ms | 9492 KB |
#include "sorting.h" #include <bits/stdc++.h> #define rep(i,a,b) for (int i=a; i<int(b); i++) using namespace std; vector<pair<int, int> > moves; int movestofix(int Ii[],int Ss[], int N) { int I[N], S[N]; rep (i,0,N) { I[i]=Ii[i];S[i]=Ss[i];} moves.clear(); //I[i] is not value at i, but index of value i in S int counter=0; rep(i,0,N) { if (S[i]==i) continue; counter++; int a,b; a=i; b=I[i]; //a och b byter plats int sa,sb; sa=S[a]; sb=S[b]; moves.push_back(make_pair(a,b)); S[a]=sb; S[b]=sa; I[sa]=b; I[sb]=a; } moves.push_back(make_pair(0,0)); return counter; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int I[N]; rep (i,0,N) { I[S[i]]=i; } int i=0; while (movestofix(I,S,N)>i) { int a,b; a=X[i]; b=Y[i]; //a och b byter plats int sa,sb; sa=S[a]; sb=S[b]; S[a]=sb; S[b]=sa; I[sa]=b; I[sb]=a; i++; } for (int j=i-1;j>=0; j--) { P[j]=moves[j].first; Q[j]=moves[j].second; rep (k,0,j) { if (moves[k].first==X[j]) moves[k].first=Y[j]; else if (moves[k].first==Y[j]) moves[k].first=X[j]; if (moves[k].second==X[j]) moves[k].second=Y[j]; else if (moves[k].second==Y[j]) moves[k].second=X[j]; } } return i; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 380 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 464 KB | Output is correct |
2 | Correct | 51 ms | 500 KB | Output is correct |
3 | Correct | 43 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 388 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 13 ms | 384 KB | Output is correct |
8 | Correct | 49 ms | 480 KB | Output is correct |
9 | Correct | 44 ms | 464 KB | Output is correct |
10 | Correct | 43 ms | 504 KB | Output is correct |
11 | Correct | 34 ms | 384 KB | Output is correct |
12 | Correct | 11 ms | 512 KB | Output is correct |
13 | Correct | 28 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 464 KB | Output is correct |
2 | Correct | 51 ms | 500 KB | Output is correct |
3 | Correct | 43 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 388 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 13 ms | 384 KB | Output is correct |
8 | Correct | 49 ms | 480 KB | Output is correct |
9 | Correct | 44 ms | 464 KB | Output is correct |
10 | Correct | 43 ms | 504 KB | Output is correct |
11 | Correct | 34 ms | 384 KB | Output is correct |
12 | Correct | 11 ms | 512 KB | Output is correct |
13 | Correct | 28 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Execution timed out | 1064 ms | 9492 KB | Time limit exceeded |
16 | Halted | 0 ms | 0 KB | - |