제출 #416983

#제출 시각아이디문제언어결과실행 시간메모리
416983wiwiho자동 인형 (IOI18_doll)C++14
76.59 / 100
105 ms12072 KiB
#include "doll.h" #include <bits/stdc++.h> #include <bits/extc++.h> #define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define iter(a) a.begin(), a.end() #define riter(a) a.rbegin(), a.rend() #define lsort(a) sort(iter(a)) #define gsort(a) sort(riter(a)) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define pf(a) push_front(a) #define ef(a) emplace_front(a) #define pob pop_back() #define pof pop_front() #define mp(a, b) make_pair(a, b) #define F first #define S second #define mt make_tuple #define gt(t, i) get<i>(t) #define tomax(a, b) ((a) = max((a), (b))) #define tomin(a, b) ((a) = min((a), (b))) #define topos(a) ((a) = (((a) % MOD + MOD) % MOD)) #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) {bool pvaspace=false; \ for(auto pva : a){ \ if(pvaspace) b << " "; pvaspace=true;\ b << pva;\ }\ b << "\n";} using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<ld, ld>; using tiii = tuple<int, int, int>; const ll MOD = 1000000007; const ll MAX = 2147483647; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } ll ifloor(ll a, ll b){ if(b < 0) a *= -1, b *= -1; if(a < 0) return (a - b + 1) / b; else return a / b; } ll iceil(ll a, ll b){ if(b < 0) a *= -1, b *= -1; if(a > 0) return (a + b - 1) / b; else return a / b; } vector<int> x(1, MAX), y(1, MAX); vector<int> a; int ts = -1; int n; vector<pair<int, pii>> leaf; int dfs(int id, int dpt, int num, pii from){ if(dpt == __lg(n - 1) + 1){ leaf.eb(mp(num, from)); return MAX; } if(id == MAX){ id = --ts; x.eb(MAX); y.eb(MAX); } if(leaf.size() < n - 1){ int tmp = dfs(x[-id - 1], dpt + 1, num, mp(-id - 1, 0)); x[-id - 1] = tmp; } if(leaf.size() < n - 1){ int tmp = dfs(y[-id - 1], dpt + 1, num + (1 << dpt), mp(-id - 1, 1)); y[-id - 1] = tmp; } return id; } int lst = -1; int dfs2(int id, int dpt){ if(id == MAX){ id = --ts; x.eb(MAX); y.eb(MAX); } // cerr << "dfs2 " << id << "\n"; if(dpt == __lg(n - 1)){ lst = -id - 1; return id; } int tmp = dfs2(y[-id - 1], dpt + 1); y[-id - 1] = tmp; return id; } void create_circuit(int m, vector<int> _a){ a = _a; vector<int> c(m + 1, -1); c[0] = a[0]; a.erase(a.begin()); a.eb(0); n = a.size(); dfs(-1, 0, 0, mp(0, 0)); dfs2(-1, 0); lsort(leaf); // printv(leaf, cerr); for(int i = 0; i < n - 1; i++){ if(leaf[i].S.S == 0) x[leaf[i].S.F] = a[i]; else y[leaf[i].S.F] = a[i]; } y[lst] = a[n - 1]; for(int i = 0; i < x.size(); i++){ if(x[i] == MAX) x[i] = -1; if(y[i] == MAX) y[i] = -1; } // printv(x, cerr); // printv(y, cerr); // printv(c, cerr); answer(c, x, y); }

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

doll.cpp: In function 'int dfs(int, int, int, pii)':
doll.cpp:80:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |     if(leaf.size() < n - 1){
      |        ~~~~~~~~~~~~^~~~~~~
doll.cpp:84:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   84 |     if(leaf.size() < n - 1){
      |        ~~~~~~~~~~~~^~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:127:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  127 |     for(int i = 0; i < x.size(); i++){
      |                    ~~^~~~~~~~~~
#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...