# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
761958 | Ahmed57 | 정렬하기 (IOI15_sorting) | C++17 | 1 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |