Submission #581931

#TimeUsernameProblemLanguageResultExecution timeMemory
5819318e7Mechanical Doll (IOI18_doll)C++17
6 / 100
125 ms17088 KiB
#include "doll.h" //Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 100005 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); vector<int> pos[maxn]; int rx[4*maxn], ry[4*maxn]; int cur; void build(int ind, vector<int> v) { if (v.size() <= 2) { if (v.size() == 1) { rx[-ind] = ind; ry[-ind] = v[0]; } else { rx[-ind] = v[0]; ry[-ind] = v[1]; } } else { vector<int> l, r; for (int i = 0;i < v.size();i++) { if (i % 2 == 0) l.push_back(v[i]); else r.push_back(v[i]); } rx[-ind] = --cur; build(cur, l); ry[-ind] = --cur; build(cur, r); } } void create_circuit(int M, std::vector<int> A) { int N = A.size(); A.push_back(0); for (int i = 0;i < N;i++) { pos[A[i]].push_back(i); } cur = 0; std::vector<int> C(M + 1); C[0] = A[0]; for (int i = 1; i <= M; ++i) { if (pos[i].size()) { vector<int> ini; for (int j:pos[i]) ini.push_back(A[j+1]); //debug(i); //pary(ini.begin(), ini.end()); C[i] = --cur; build(cur, ini); } else { C[i] = i; } } int S = -cur; std::vector<int> X(S), Y(S); for (int k = 1; k <= S; ++k) { X[k-1] = rx[k], Y[k-1] = ry[k]; } pary(C.begin(), C.end()); pary(X.begin(), X.end()); pary(Y.begin(), Y.end()); answer(C, X, Y); } /* 4 4 1 2 1 3 */

Compilation message (stderr)

doll.cpp: In function 'void build(int, std::vector<int>)':
doll.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int i = 0;i < v.size();i++) {
      |                  ~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
doll.cpp:73:2: note: in expansion of macro 'pary'
   73 |  pary(C.begin(), C.end());
      |  ^~~~
doll.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
doll.cpp:74:2: note: in expansion of macro 'pary'
   74 |  pary(X.begin(), X.end());
      |  ^~~~
doll.cpp:14:19: warning: statement has no effect [-Wunused-value]
   14 | #define pary(...) 0
      |                   ^
doll.cpp:75:2: note: in expansion of macro 'pary'
   75 |  pary(Y.begin(), Y.end());
      |  ^~~~
#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...