Submission #973463

#TimeUsernameProblemLanguageResultExecution timeMemory
973463kwongwengMechanical Doll (IOI18_doll)C++17
47 / 100
83 ms19900 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef vector<vector<ll>> vll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define pb push_back #define ms memset #define fi first #define se second const int mxN = 1e6+1; int cur = 1; vi X(mxN),Y(mxN),C; void build(int i, vi nxt){ if (nxt.size()==2){ X[i-1] = nxt[0]; Y[i-1] = nxt[1]; return; } int len = nxt.size(); if (len % 2 == 0){ X[i-1] = -cur; cur++; vi Nxt; for (int j = 0; j < len; j+=2) Nxt.pb(nxt[j]); build(cur-1,Nxt); Nxt.clear(); for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]); Y[i-1] = -cur; cur++; build(cur-1,Nxt); }else{ X[i-1] = -cur; cur++; vi Nxt; for (int j = 0; j < len-1; j+=2) Nxt.pb(nxt[j]); Nxt.pb(-i); build(cur-1,Nxt); Nxt.clear(); for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]); Y[i-1] = -cur; cur++; Nxt.pb(nxt[len-1]); build(cur-1,Nxt); } } void create_circuit(int M, vi A) { int N = A.size(); C.resize(M+1); C[0] = A[0]; if (A.size()==1){ answer(C,{},{}); return; } FOR(i,1,M+1) C[i] = -1; cur++; vi nxt; FOR(i,1,A.size()) nxt.pb(A[i]); nxt.pb(0); build(1,nxt); vi x(cur-1), y(cur-1); FOR(i,0,cur-1){ x[i]=X[i]; y[i]=Y[i]; } answer(C, x, y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, vi)':
doll.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   57 |   FOR(i,1,A.size()) nxt.pb(A[i]);
      |       ~~~~~~~~~~~~                     
doll.cpp:57:3: note: in expansion of macro 'FOR'
   57 |   FOR(i,1,A.size()) nxt.pb(A[i]);
      |   ^~~
doll.cpp:48:7: warning: unused variable 'N' [-Wunused-variable]
   48 |   int N = A.size();
      |       ^
#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...