제출 #137293

#제출 시각아이디문제언어결과실행 시간메모리
137293Nucleist정렬하기 (IOI15_sorting)C++14
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; #define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define ll long long #define INF 1000000000 #define pb push_back struct greateri { template<class T> bool operator()(T const &a, T const &b) const { return a > b; } }; int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]) { int r = 0; bool ka = false; for (int i = 0; i < N; ++i) {if(i!=S[i]){ka=true;break;}} if(!ka)return r; int k1 = S[0]; int vol1 = S[1]; S[0]=vol1; S[1]=k1; for (int i = 2; i < N; ++i) { if((S[i]==0) || (S[i]==1)) { int k = S[i]; int now = k; if(S[k]==0 || S[k]==1) { if(S[k]==0)now--; else now++; } int vol = S[now]; S[i]=vol; S[now]=k; P[r]=i; Q[r]=now; r++; bool ka1 = false; for (int i = 0; i < N; ++i) {if(i!=S[i]){ka1=true;break;}} if(!ka1)return r; int k1 = S[0]; int vol1 = S[1]; S[0]=vol1; S[1]=k1; break; } } for (int i = 2; i < N; ++i) { if((S[i]==0) || (S[i]==1)) { int k = S[i]; int now = k; if(S[k]==0 || S[k]==1) { if(S[k]==0)now--; else now++; } int vol = S[now]; S[i]=vol; S[now]=k; P[r]=i; Q[r]=now; r++; bool ka1 = false; for (int i = 0; i < N; ++i) {if(i!=S[i]){ka1=true;break;}} if(!ka1)return r; int k1 = S[0]; int vol1 = S[1]; S[0]=vol1; S[1]=k1; break; } } for (int i = 2; i < N; ++i) { while(i!=S[i]) { int k = S[i]; int vol = S[k]; S[i]=vol; S[k]=k; P[r]=i; Q[r]=k; r++; bool ka1=false; for (int i = 0; i < N; ++i) {if(i!=S[i]){ka1=true;break;}} if(!ka1)return r; int k1 = S[0]; int vol1 = S[1]; S[0]=vol1; S[1]=k1; } } if(S[0]==0){P[r]=0;Q[r]=0;return r+1;} P[r]=1;Q[r]=0;return r+1; }

컴파일 시 표준 에러 (stderr) 메시지

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:46:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for (int i = 0; i < N; ++i)
              ^
sorting.cpp:28:12: note: shadowed declaration is here
   for (int i = 2; i < N; ++i)
            ^
sorting.cpp:49:9: warning: declaration of 'k1' shadows a previous local [-Wshadow]
     int k1 = S[0];
         ^~
sorting.cpp:24:7: note: shadowed declaration is here
   int k1 = S[0];
       ^~
sorting.cpp:50:9: warning: declaration of 'vol1' shadows a previous local [-Wshadow]
     int vol1 = S[1];
         ^~~~
sorting.cpp:25:7: note: shadowed declaration is here
   int vol1 = S[1];
       ^~~~
sorting.cpp:74:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for (int i = 0; i < N; ++i)
              ^
sorting.cpp:56:12: note: shadowed declaration is here
   for (int i = 2; i < N; ++i)
            ^
sorting.cpp:77:9: warning: declaration of 'k1' shadows a previous local [-Wshadow]
     int k1 = S[0];
         ^~
sorting.cpp:24:7: note: shadowed declaration is here
   int k1 = S[0];
       ^~
sorting.cpp:78:9: warning: declaration of 'vol1' shadows a previous local [-Wshadow]
     int vol1 = S[1];
         ^~~~
sorting.cpp:25:7: note: shadowed declaration is here
   int vol1 = S[1];
       ^~~~
sorting.cpp:96:14: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for (int i = 0; i < N; ++i)
              ^
sorting.cpp:84:12: note: shadowed declaration is here
   for (int i = 2; i < N; ++i)
            ^
sorting.cpp:99:9: warning: declaration of 'k1' shadows a previous local [-Wshadow]
     int k1 = S[0];
         ^~
sorting.cpp:24:7: note: shadowed declaration is here
   int k1 = S[0];
       ^~
sorting.cpp:100:9: warning: declaration of 'vol1' shadows a previous local [-Wshadow]
     int vol1 = S[1];
         ^~~~
sorting.cpp:25:7: note: shadowed declaration is here
   int vol1 = S[1];
       ^~~~
sorting.cpp:17:37: warning: unused parameter 'M' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int  P[],int Q[])
                                     ^
sorting.cpp:17:45: warning: unused parameter 'X' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int  P[],int Q[])
                                             ^
sorting.cpp:17:53: warning: unused parameter 'Y' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int  P[],int Q[])
                                                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...