제출 #288945

#제출 시각아이디문제언어결과실행 시간메모리
288945arman_ferdous자동 인형 (IOI18_doll)C++17
2 / 100
89 ms14620 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; const int M = 1e5+10; const int N = 2e5+10; int m, n; vector<int> C, X, Y; int newnode, root[N], previousRoot; int le[N + N], ri[N + N], parity[N + N]; vector<int> neighbour[M]; void build(int u, int L, int R) { if(L == R) return; int mid = L + R >> 1; le[u] = ++newnode; ri[u] = ++newnode; build(le[u], L, mid); build(ri[u], mid + 1, R); } void assign(int u, int to) { if(parity[u] & 1) { parity[u] ^= 1; if(ri[u]) assign(ri[u], to); else ri[u] = to; } else { parity[u] ^= 1; if(le[u]) assign(le[u], to); else le[u] = to; } } void process(int val) { int sz = neighbour[val].size(); if(sz & 1) { root[val] = ++newnode; build(root[val], 1, (sz + 1) / 2); for(int i = 0; i < sz; i++) assign(root[val], -neighbour[val][i]); } else { root[val] = ++newnode; build(root[val], 1, (sz + 2) / 2); for(int i = 0; i < sz; i++) assign(root[val], -neighbour[val][i]); assign(root[val], root[val]); } if(previousRoot) { assign(root[val], previousRoot); previousRoot = root[val]; } else { assign(root[val], 0); previousRoot = root[val]; } } void create_circuit(int M, std::vector<int> A) { n = A.size(), m = M; int processLast = A[n - 1]; for(int i = 0; i + 1 < n; i++) { neighbour[A[i]].push_back(A[i + 1]); } C.resize(m + 1); C[0] = A[0]; for(int i = 1; i <= m; i++) if(i != processLast) { if(neighbour[i].empty()) C[i] = 0; else { process(i); C[i] = -root[i]; } } process(processLast); C[processLast] = -root[processLast]; X.resize(newnode); Y.resize(newnode); for(int i = 1; i <= newnode; i++) X[i - 1] = -le[i], Y[i - 1] = -ri[i]; answer(C, X, Y); }

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

doll.cpp: In function 'void build(int, int, int)':
doll.cpp:17:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |   int mid = L + R >> 1;
      |             ~~^~~
#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...