Submission #1142190

#TimeUsernameProblemLanguageResultExecution timeMemory
1142190alimkhanMechanical Doll (IOI18_doll)C++20
0 / 100
0 ms324 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second const int maxn = 1e6 + 10; int n, s, a[maxn], pw, l; vector <int> X, Y; vector <int> c; map <int, int> lf, rg; void get(int v, int tl, int tr) { int tm = (tl + tr) / 2; if (tm <= l) { lf[v] = -1; } if (tm + 1 == tr) { rg[v] = a[tr]; } else { s--; rg[v] = s; get(s, tm + 1, tr); } if (tl == tm && lf[v] == 0) { lf[v] = a[tl]; } else { if (lf[v] == 0) { s--; lf[v] = s; get(s, tl, tm); } } } void create_circuit(int M, std::vector<int> A) { n = A.size(); pw = 2; while(pw < n) { pw *= 2; } while(l + n < pw) { l++; a[l] = -1; } int id = l + 1; for (int i = 0; i < n; i++) { if (i % 2 == 0) { a[id] = A[i]; id++; } } for (int i = 0; i < n; i++) { if (i % 2 != 0) { a[id] = A[i]; id++; } } s = -1; get(-1, 1, pw); for (int i = 0; i < n - 1; i++) { c.push_back(-1); } c.push_back(0); for (int i = -1; i >= s; i--) { X.push_back(lf[i]); Y.push_back(rg[i]); } answer(c, X, Y); }
#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...