제출 #674816

#제출 시각아이디문제언어결과실행 시간메모리
674816QwertyPiShuffle (NOI19_shuffle)C++14
0 / 100
6 ms852 KiB
#include "shuffle.h" #include <bits/stdc++.h> #ifdef ONLINE_JUDGE #define cout cerr #endif using namespace std; using v2d = vector<vector<int>>; using v1d = vector<int>; int N, B, K; v2d self_suffle(v2d query){ for(auto& q : query){ for(auto& i : q){ i = (i % N + N) % N + 1; } } return shuffle(query); } void norm(v2d& v2){ for(auto& v : v2){ sort(v.begin(), v.end()); } sort(v2.begin(), v2.end()); } const int MAXN = 1e4 + 11; vector<int> G[MAXN]; deque<int> val; bool vis[MAXN]; int c[MAXN]; void dfs(int v, int pa = -1){ vis[v] = true; val.push_back(v); for(auto i : G[v]){ if(i != pa && !vis[i]) c[i] = c[v] ^ 1, dfs(i, v); } } bool is_adj(int u, int v){ for(auto i : G[u]){ if(i == v) return true; } return false; } int adj_exc(int u, int v){ for(auto i : G[u]){ if(i != v) return i; } return -1; } ostream& operator<< (ostream& out, v2d v){ out << "Vec2d: " << endl; for(auto i : v){ for(auto ii : i){ out << ii << ' '; } out << endl; } return out << endl; } ostream& operator<< (ostream& out, v1d v){ out << "Vec1d: " << endl; for(auto i : v){ out << i << ' '; } return out << endl; } vector<int> solve(int N, int B, int K, int Q, int ST) { ::N = N, ::B = B, ::K = K; vector<int> ans(N); if(K == 2){ v2d query, res; for(int i = 0; i < B; i++){ query.push_back({i * 2, i * 2 + 1}); } res = self_suffle(query); for(auto p : res){ G[p[0]].push_back(p[1]); G[p[1]].push_back(p[0]); } query.clear(); for(int i = 0; i < B; i++){ query.push_back({i * 2, i * 2 - 1}); } res = self_suffle(query); for(auto p : res){ G[p[0]].push_back(p[1]); G[p[1]].push_back(p[0]); } dfs(1); query.clear(); query.push_back({0, 2}); query.push_back({1, 3}); for(int i = 2; i < B; i++){ query.push_back({i * 2, i * 2 + 1}); } v2d v1 = self_suffle(query); query.clear(); query.push_back({0, 2}); query.push_back({3, 5}); query.push_back({1, 4}); for(int i = 3; i < B; i++){ query.push_back({i * 2, i * 2 + 1}); } v2d v2 = self_suffle(query); norm(v1), norm(v2); cout << v1 << v2; v2d s1, s2; for(int i = 0; i < B; i++){ if(c[v1[i][0]] == c[v1[i][1]]) s1.push_back(v1[i]); if(c[v2[i][0]] == c[v2[i][1]]) s2.push_back(v2[i]); } for(int i = 1; i <= N; i++) cout << c[i] << ' '; cout << endl; v1d a02; for(int i = 0; i < 2; i++){ if(s1[i] == s2[i]){ a02 = s1[i]; }else{ if(s1[i][0] == s2[i][0] || s1[i][1] == s2[i][0]) ans[3] = s2[i][0]; else ans[3] = s2[i][1]; } } cout << a02 << ans[3]; if(is_adj(a02[0], ans[3])) ans[2] = a02[0], ans[0] = a02[1]; else ans[2] = a02[1], ans[0] = a02[0]; ans[1] = adj_exc(ans[2], ans[3]); for(int i = 4; i < N; i++){ cout << ans[i - 1] << ' ' << ans[i - 2] << endl; ans[i] = adj_exc(ans[i - 1], ans[i - 2]); } } cout << ans; return ans; }

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

shuffle.cpp: In function 'std::vector<int> solve(int, int, int, int, int)':
shuffle.cpp:121:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  121 |   for(int i = 1; i <= N; i++) cout << c[i] << ' '; cout << endl;
      |   ^~~
shuffle.cpp:121:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  121 |   for(int i = 1; i <= N; i++) cout << c[i] << ' '; cout << endl;
      |                                                    ^~~~
#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...