제출 #503600

#제출 시각아이디문제언어결과실행 시간메모리
503600snasibov05자동 인형 (IOI18_doll)C++14
2 / 100
63 ms7724 KiB
#include "doll.h" #include <queue> using namespace std; void create_circuit(int m, vector<int> a) { int n = a.size(); vector<vector<int>> to(m+1); to[0].push_back(a[0]); to[a[n-1]].push_back(0); for (int i = 0; i < n-1; ++i){ to[a[i]].push_back(a[i+1]); } vector<int> x, y; vector<bool> state; int cur = -1; vector<int> c(m+1); for (int i = 0; i <= m; ++i){ int k = 0, b = 1; while (to[i].size() > b) b *= 2, k++; if (k == 0){ if (to[i].empty()) c[i] = 0; else c[i] = to[i][0]; continue; } int src = cur; int mx = cur - b + 2; c[i] = cur--; queue<int> q; q.push(cur+1); while (!q.empty()){ state.push_back(true); q.pop(); if (cur < mx) { x.push_back(0); y.push_back(0); continue; } x.push_back(cur--); y.push_back(cur--); q.push(x.back()); q.push(y.back()); } int rem = b - (int)to[i].size(); for (int j = 0; j < to[i].size() - rem; ++j){ int pos = src; for (int l = 0; l < k-1; ++l) { if (state[-pos-1]) { state[-pos-1] = false; pos = x[-pos-1]; } else{ state[-pos-1] = true; pos = y[-pos-1]; } } if (state[-pos-1]) { state[-pos-1] = false; x[-pos-1] = to[i][j]; } else{ state[-pos-1] = true; y[-pos-1] = to[i][j]; } } for (int j = to[i].size() - rem; j < to[i].size(); ++j){ int pos = src; for (int l = 0; l < k-1; ++l) { if (state[-pos-1]) { state[-pos-1] = false; pos = x[-pos-1]; } else{ state[-pos-1] = true; pos = y[-pos-1]; } } if (state[-pos-1]) { state[-pos-1] = false; x[-pos-1] = src; } else{ state[-pos-1] = true; y[-pos-1] = src; } pos = src; for (int l = 0; l < k-1; ++l) { if (state[-pos-1]) { state[-pos-1] = false; pos = x[-pos-1]; } else{ state[-pos-1] = true; pos = y[-pos-1]; } } if (state[-pos-1]) { state[-pos-1] = false; x[-pos-1] = to[i][j]; } else{ state[-pos-1] = true; y[-pos-1] = to[i][j]; } } } answer(c, x, y); }

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

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:24:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |         while (to[i].size() > b) b *= 2, k++;
      |                ~~~~~~~~~~~~~^~~
doll.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for (int j = 0; j < to[i].size() - rem; ++j){
      |                         ~~^~~~~~~~~~~~~~~~~~~~
doll.cpp:73:44: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for (int j = to[i].size() - rem; j < to[i].size(); ++j){
      |                                          ~~^~~~~~~~~~~~~~
#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...