# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
761958 | 2023-06-20T12:49:59 Z | Ahmed57 | 정렬하기 (IOI15_sorting) | C++17 | 1 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; int lol[100001],vis[100001]; vector<int> v; void dfs(int i){ vis[i] = 1; v.push_back(i); if(vis[lol[i]]==0)dfs(lol[i]); } int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]){ int ans = 0; swap(S[0],S[1]); int on = 0 , ze = 0; for(int i = 0;i<N;i++){ if(S[i]==0)ze = i; if(S[i]==1)on = i; } if(ze>1){ swap(S[(on?0:1)],S[ze]); P[0] = ze , Q[0] = (on?0:1); cout<<ze<<"hh"<<endl; ans++; swap(S[0],S[1]); if(on>1){ swap(S[0],S[on]); P[1] = 0 , Q[1] = on; ans++; swap(S[0],S[1]); } }else if(on>1){ if(ze==0){ P[0] = on; Q[0] = 1; ans++; }else{ P[0] = on; Q[0] = 0; ans++; } swap(S[0],S[1]); } for(int i = 0;i<N;i++){ lol[i] = S[i]; vis[i] = 0; } int ha = -1; for(int i = 2;i<N;i++){ if(vis[i]==0){ v.clear(); dfs(i); for(int j = 1;j<v.size();j++){ ha++; P[ans] = v[0]; Q[ans] = v[j]; ans++; } } } if(ha==-1){ if(S[0]==1){ return ans; }else{ P[ans] = 0; Q[ans] = 0; ans++; return ans; } }else{ int pr = ha%2; if(S[pr]==0){ return ans; }else{ P[ans] = 0; Q[ans] = 0; ans++; return ans; } } } /* int main(){ int S[] = {4,3,2,1,0}; int X[] = {0,0,0,0,0,0,0,0,0,0,0}; int Y[] = {1,1,1,1,1,1,1,1,1,1,1}; cout<<findSwapPairs(5,S,100,X,Y)<<endl; for(int i = 0;i<10;i++){ cout<<P[i]<<" "<<Q[i]<<endl; } } */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Incorrect | 1 ms | 304 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Incorrect | 1 ms | 304 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 312 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Incorrect | 1 ms | 304 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 504 KB | Expected integer, but "688hh" found |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 504 KB | Expected integer, but "688hh" found |
2 | Halted | 0 ms | 0 KB | - |