제출 #295762

#제출 시각아이디문제언어결과실행 시간메모리
295762Bruteforceman자동 인형 (IOI18_doll)C++11
37 / 100
252 ms30752 KiB
#include "bits/stdc++.h" #include "doll.h" using namespace std; const int maxn = 5e5 + 10; vector <int> g[maxn]; int l[maxn], r[maxn]; bool leaf[maxn]; int to[maxn]; int node = 0; int create(int b, int e, vector <int> &order) { int cur = ++node; if(b == e) { leaf[cur] = true; order.push_back(cur); order.push_back(cur); return cur; } int mid = (b + e) >> 1; vector <int> left, right; l[cur] = create(b, mid, left); r[cur] = create(mid + 1, e, right); for(int i = 0; i < left.size(); i++) { order.push_back(left[i]); order.push_back(right[i]); } return cur; } void getEdges(int root, vector <int> v) { if(v.empty()) return ; int sz = 1; while(2 * sz < v.size()) sz *= 2; vector <int> order; to[root] = -create(1, sz, order); set <int> cont; int pt = 0; for(int i = 0; i < order.size(); i++) { if(cont.count(order[i])) { if(i >= order.size() - v.size()) { r[order[i]] = v[pt++]; } else { r[order[i]] = to[root]; } } else { if(i >= order.size() - v.size()) { l[order[i]] = v[pt++]; } else { l[order[i]] = to[root]; } } cont.insert(order[i]); } } void create_circuit(int M, std::vector<int> A) { int N = A.size(); A.insert(A.begin(), 0); A.insert(A.end(), 0); for(int i = 1; i < A.size(); i++) { g[A[i - 1]].push_back(A[i]); } for(int i = 0; i <= M; i++) { getEdges(i, g[i]); } vector <int> C(M + 1); vector <int> X (node), Y (node); for(int i = 0; i <= M; i++) { C[i] = to[i]; } for(int i = 1; i <= node; i++) { if(leaf[i]) { X[i - 1] = l[i]; Y[i - 1] = r[i]; } else { X[i - 1] = -l[i]; Y[i - 1] = -r[i]; } } answer(C, X, Y); }

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

doll.cpp: In function 'int create(int, int, std::vector<int>&)':
doll.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i = 0; i < left.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
doll.cpp: In function 'void getEdges(int, std::vector<int>)':
doll.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   while(2 * sz < v.size()) sz *= 2;
      |         ~~~~~~~^~~~~~~~~~
doll.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int i = 0; i < order.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
doll.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if(i >= order.size() - v.size()) {
      |          ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
doll.cpp:45:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |       if(i >= order.size() - v.size()) {
      |          ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for(int i = 1; i < A.size(); i++) {
      |                  ~~^~~~~~~~~~
doll.cpp:56:7: warning: unused variable 'N' [-Wunused-variable]
   56 |   int N = A.size();
      |       ^
#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...