제출 #422742

#제출 시각아이디문제언어결과실행 시간메모리
422742alireza_kaviani자동 인형 (IOI18_doll)C++11
0 / 100
20 ms4248 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; int cnt , ans[MAXN]; vector<int> vec , C , X , Y; int reverse(int x){ int ans = 0; for(int i = 0 ; i < cnt ; i++){ ans = ans * 2 + ((x & (1 << i)) != 0); } return ans; } int solve(int ql , int qr , int l , int r){ if(r <= ql || qr <= l) return -1; if(r - l == 1) return ans[l]; int id = X.size(); X.push_back(-1); Y.push_back(-1); int mid = l + r >> 1; int a = solve(ql , qr , l , mid); int b = solve(ql , qr , mid , r); X[id] = a; Y[id] = b; return -(id + 1); } void create_circuit(int M, vector<int> A) { fill(ans , ans + MAXN , -1); int k = 1 , n = A.size(); while(k < n) k *= 2 , cnt++; for(int i = k - n ; i < k ; i++){ vec.push_back(reverse(i)); } sort(vec.begin() , vec.end()); C.push_back(A[0]); for(int i = 0 ; i < n ; i++){ ans[reverse(vec[i])] = (i + 1 < n ? A[i + 1] : 0); C.push_back(-1); } /* for(int i = 0 ; i < k ; i++){ cout << ans[i] << endl; } */ solve(k - n , k , 0 , k); /* for(int i : C) cout << i << ' '; cout << endl; for(int i : X) cout << i << ' '; cout << endl; for(int i : Y) cout << i << ' '; cout << endl;*/ answer(C , X , Y); }

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

doll.cpp: In function 'int solve(int, int, int, int)':
doll.cpp:23:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |  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...