# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140224 | 2019-08-02T10:13:28 Z | rajarshi_basu | Mechanical Doll (IOI18_doll) | C++14 | 177 ms | 22684 KB |
#include <bits/stdc++.h> #include "doll.h" #define FOR(i,n) for(int i = 0;i<n;i++) #define FORE(i,a,b) for(int i= a;i<=b;i++) #define ll long long int #define vi vector<int> #define vv vector #define pb push_back #define ii pair<int,int> using namespace std; const int MAXN = 4e5; int n,m; vi out[MAXN]; int ctr = 1; int x[MAXN]; int y[MAXN]; bool dummy[MAXN]; void ans1wer(vi a,vi b,vi c){ for(auto e : a)cout << e << " ";cout << endl; FOR(i,b.size()){ cout << b[i] << " " << c[i] << endl; } } int solve(vi nums){ if(nums.size() == 1){ return nums[0]; } vi lft;vi rght; FOR(i,nums.size()){ if(i%2 == 0){ lft.pb(nums[i]); }else{ rght.pb(nums[i]); } } int xx = solve(lft); int yy = solve(rght); x[ctr] = xx; y[ctr] = yy; ctr++; return -(ctr-1); } void create_circuit(int m,vi a){ ::m = m; n = a.size(); FOR(i,n){ if(i == n-1){ out[a[i]].pb(0); }else{ out[a[i]].pb(a[i+1]); } } out[0].pb(a[0]); vi outof(m+1); FOR(i,m+1){ if(out[i].size() == 0){ outof[i] = 0; }else{ int kk = out[i].size(); int lst = out[i].back(); out[i].pop_back(); vi ids; while((kk&(kk-1)) != 0){ out[i].pb(-ctr); dummy[ctr] = 1; x[ctr] = -ctr; ids.pb(ctr); kk++; ctr++; } out[i].pb(lst); outof[i] = solve(out[i]); for(auto e: ids)y[e] = outof[i]; } } vi xx; vi yy; FORE(i,1,ctr-1){ xx.pb(x[i]); yy.pb(y[i]); } //ans1wer(outof,xx,yy); answer(outof,xx,yy); } int mai1n(){ vi all; all.pb(1); all.pb(2); all.pb(1); all.pb(3); all.pb(1); all.pb(4); //all.pb(1); create_circuit(4,all); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9604 KB | Output is correct |
2 | Correct | 52 ms | 13388 KB | Output is correct |
3 | Correct | 33 ms | 13004 KB | Output is correct |
4 | Correct | 7 ms | 9676 KB | Output is correct |
5 | Correct | 17 ms | 10828 KB | Output is correct |
6 | Correct | 47 ms | 14660 KB | Output is correct |
7 | Correct | 6 ms | 9676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9604 KB | Output is correct |
2 | Correct | 52 ms | 13388 KB | Output is correct |
3 | Correct | 33 ms | 13004 KB | Output is correct |
4 | Correct | 7 ms | 9676 KB | Output is correct |
5 | Correct | 17 ms | 10828 KB | Output is correct |
6 | Correct | 47 ms | 14660 KB | Output is correct |
7 | Correct | 6 ms | 9676 KB | Output is correct |
8 | Correct | 68 ms | 15580 KB | Output is correct |
9 | Correct | 73 ms | 15956 KB | Output is correct |
10 | Correct | 127 ms | 18920 KB | Output is correct |
11 | Correct | 9 ms | 9676 KB | Output is correct |
12 | Correct | 9 ms | 9676 KB | Output is correct |
13 | Correct | 8 ms | 9676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9604 KB | Output is correct |
2 | Correct | 52 ms | 13388 KB | Output is correct |
3 | Correct | 33 ms | 13004 KB | Output is correct |
4 | Correct | 7 ms | 9676 KB | Output is correct |
5 | Correct | 17 ms | 10828 KB | Output is correct |
6 | Correct | 47 ms | 14660 KB | Output is correct |
7 | Correct | 6 ms | 9676 KB | Output is correct |
8 | Correct | 68 ms | 15580 KB | Output is correct |
9 | Correct | 73 ms | 15956 KB | Output is correct |
10 | Correct | 127 ms | 18920 KB | Output is correct |
11 | Correct | 9 ms | 9676 KB | Output is correct |
12 | Correct | 9 ms | 9676 KB | Output is correct |
13 | Correct | 8 ms | 9676 KB | Output is correct |
14 | Incorrect | 177 ms | 22684 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 9640 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 9676 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 9676 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |