제출 #75412

#제출 시각아이디문제언어결과실행 시간메모리
75412KieranHorgan자동 인형 (IOI18_doll)C++17
26 / 100
226 ms21100 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; vector<int> A, X, Y, C; int dep[200]; int nextSwitch = -1; vector<int> AdjList[200005]; int globalCurSwitch; int recurseThroughTree(vector<int> b) { if(b.size() == 1) return b[0]; int curSwitch = nextSwitch--; vector<int> a; a.clear(); int nextDummies = 0; for(int i = 0; i < b.size(); i+=2) { if(b[i] == globalCurSwitch) nextDummies++; a.push_back(b[i]); } int l; if(nextDummies == a.size()) { l = globalCurSwitch; } else { l = recurseThroughTree(a); } a.clear(); for(int i = 1; i < b.size(); i+=2) { if(b[i] == globalCurSwitch) nextDummies++; a.push_back(b[i]); } int r = recurseThroughTree(a); if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch)); X[abs(curSwitch)-1] = l; Y[abs(curSwitch)-1] = r; return curSwitch; } bitset<200005> is; void buildTree(int curTrigger, int curSwitch) { globalCurSwitch = curSwitch; int x = AdjList[curTrigger].size(); int dummies = 0; while(__builtin_popcount(x+dummies) != 1) dummies++; // cerr << curTrigger << ": " << x+dummies << " " << dummies << endl; vector<int> b = AdjList[curTrigger]; vector<int> pos, posCop; if(pos.size() != dummies) pos = {0}; for(int i = x+dummies; i > 1; i /= 2) { if(pos.size() == dummies) break; posCop = pos; for(auto x: posCop) { pos.push_back(x+(i/2)); if(pos.size() == dummies) break; } // cerr << i << " " << pos.size() << endl; } is.reset(); for(auto x: pos) is[x]=1; pos.clear(); posCop.clear(); vector<int> a; for(int j = 0, i = 0; j < x+dummies; j++) { if(is[j]) a.push_back(globalCurSwitch); else a.push_back(b[i++]); } b = a; a.clear(); int nextDummies = 0; for(int i = 0; i < b.size(); i+=2) { a.push_back(b[i]); } int l = recurseThroughTree(a); a.clear(); nextDummies = 0; for(int i = 1; i < b.size(); i+=2) { a.push_back(b[i]); } int r = recurseThroughTree(a); a.clear(); if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch)); X[abs(curSwitch)-1] = l; Y[abs(curSwitch)-1] = r; } void create_circuit(int M, vector<int> A_) { A = A_; int N = A.size(); if(!A.empty()) { AdjList[0].push_back(A[0]); for(int i = 0; i+1 < A.size(); i++) { AdjList[A[i]].push_back(A[i+1]); } AdjList[A.back()].push_back(0); } C.assign(M+1, 0); for(int i = 0; i <= M; i++) { if(AdjList[i].empty()) { } else if(AdjList[i].size() == 1) { C[i] = AdjList[i][0]; } else { C[i] = nextSwitch--; buildTree(i, C[i]); // for(int j = C[i]; j > nextSwitch; j--) { // cerr << j << ": " << X[abs(j)-1] << " " << Y[abs(j)-1] << endl; // } } } double score; int S = X.size(); // cerr << S << " " << N+log2(N) << endl; if(S <= N + log2(N)) score = 1; else if(S <= 2*N) score = 0.5 + 0.4*((2*N - S)/(N-log2(N)))*((2*N - S)/(N-log2(N))); else score = 0; score *= 100; // cout << "Score: " << setprecision(7) << fixed << score << "\t"; answer(C, X, Y); }

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

doll.cpp: In function 'int recurseThroughTree(std::vector<int>)':
doll.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i = 0; i < b.size(); i+=2) {
      |                  ~~^~~~~~~~~~
doll.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if(nextDummies == a.size()) {
      |      ~~~~~~~~~~~~^~~~~~~~~~~
doll.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i = 1; i < b.size(); i+=2) {
      |                  ~~^~~~~~~~~~
doll.cpp:38:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch));
      |      ~~~~~~~~~^~~~~~~~~~~~~~~~~~~
doll.cpp: In function 'void buildTree(int, int)':
doll.cpp:58:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   if(pos.size() != dummies)
      |      ~~~~~~~~~~~^~~~~~~~~~
doll.cpp:61:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |     if(pos.size() == dummies)
      |        ~~~~~~~~~~~^~~~~~~~~~
doll.cpp:66:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |       if(pos.size() == dummies)
      |          ~~~~~~~~~~~^~~~~~~~~~
doll.cpp:87:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |   for(int i = 0; i < b.size(); i+=2) {
      |                  ~~^~~~~~~~~~
doll.cpp:94:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |   for(int i = 1; i < b.size(); i+=2) {
      |                  ~~^~~~~~~~~~
doll.cpp:100:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  100 |   if(X.size() <= abs(curSwitch)-1) X.resize(abs(curSwitch)), Y.resize(abs(curSwitch));
      |      ~~~~~~~~~^~~~~~~~~~~~~~~~~~~
doll.cpp:86:7: warning: variable 'nextDummies' set but not used [-Wunused-but-set-variable]
   86 |   int nextDummies = 0;
      |       ^~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:111:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |     for(int i = 0; i+1 < A.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...