제출 #41875

#제출 시각아이디문제언어결과실행 시간메모리
41875funcsrSorting (IOI15_sorting)C++14
0 / 100
445 ms16248 KiB
#include "sorting.h" #include <vector> #include <iostream> #include <algorithm> #include <queue> #include <cassert> using namespace std; #define rep(i, n) for (int i=0; i<(n); i++) #define pb push_back #define _1 first #define _2 second #define INF 1145141919 #define MOD 1000000007 bool used[200000]; vector<int> G[200000]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { // subtask 1-4 rep(i, N) used[i] = false; for (int i=M-1; i>=0; i--) { if (X[i] == Y[i]) continue; if (!used[X[i]]) { G[i].pb(X[i]); used[X[i]] = true; } if (!used[Y[i]]) { G[i].pb(Y[i]); used[Y[i]] = true; } } rep(i, N) if (!used[i]) G[0].pb(i); vector<int> ps; rep(i, M) { swap(S[X[i]], S[Y[i]]); for (int t : G[i]) ps.pb(t); vector<int> nps; for (int x : ps) if (S[x] != x) nps.pb(x); swap(ps, nps); if (ps.empty()) { P[i] = Q[i] = 0; continue; } cout<<"ps:{";for (int x :ps)cout<<x<<",";cout<<"}\n"; bool ok = false; rep(i, ps.size()) rep(j, i) { if (ok) break; int x = ps[i], y = ps[j]; if (S[x] == y && x == S[y]) { ok = true; swap(S[x], S[y]); P[i] = x, Q[i] = y; break; } } if (!ok) { int x = ps[0], y = -1; rep(i, N) if (S[i] == x) y = i; swap(S[x], S[y]); P[i] = x, Q[i] = y; } } rep(i, N) assert(S[i] == i); assert(ps.empty()); return M; }

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:45:9: warning: declaration of 'i' shadows a previous local [-Wshadow]
     rep(i, ps.size()) rep(j, i) {
         ^
sorting.cpp:8:28: note: in definition of macro 'rep'
 #define rep(i, n) for (int i=0; i<(n); i++)
                            ^
sorting.cpp:33:7: note: shadowed declaration is here
   rep(i, M) {
       ^
sorting.cpp:8:28: note: in definition of macro 'rep'
 #define rep(i, n) for (int i=0; i<(n); i++)
                            ^
sorting.cpp:8:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i, n) for (int i=0; i<(n); i++)
                                  ^
sorting.cpp:45:5: note: in expansion of macro 'rep'
     rep(i, ps.size()) rep(j, i) {
     ^~~
sorting.cpp:57:11: warning: declaration of 'i' shadows a previous local [-Wshadow]
       rep(i, N) if (S[i] == x) y = i;
           ^
sorting.cpp:8:28: note: in definition of macro 'rep'
 #define rep(i, n) for (int i=0; i<(n); i++)
                            ^
sorting.cpp:33:7: note: shadowed declaration is here
   rep(i, M) {
       ^
sorting.cpp:8:28: note: in definition of macro 'rep'
 #define rep(i, n) for (int i=0; i<(n); i++)
                            ^
#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...