# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
944108 | 2024-03-12T08:34:01 Z | shoryu386 | Mechanical Doll (IOI18_doll) | C++17 | 63 ms | 12496 KB |
#include <bits/stdc++.h> using namespace std; #include "doll.h" int ptr = -1; vector<int> xLead, yLead; int construct(vector<int> item){ if (item.size() == 1){ return item[0]; } vector<int> itemLeft, itemRight; for (int x = 0; x < item.size(); x+=2){ itemLeft.push_back(item[x]); } for (int x = 1; x < item.size(); x+=2){ itemRight.push_back(item[x]); } int curNode = ptr; //cerr << "Construct " << curNode << '\n'; //for (auto y : item) cerr << y << ' '; //cerr << '\n'; ptr--; xLead.push_back( construct(itemLeft) ); yLead.push_back( construct(itemRight) ); return curNode; } void create_circuit(int m, std::vector<int> A) { int n = A.size(); xLead.clear(); yLead.clear(); ptr = -1; vector<int> leads[m+1]; leads[0].push_back(A[0]); for (int x = 0; x < n-1; x++){ leads[A[x]].push_back(A[x+1]); } leads[A[n-1]].push_back(0); vector<int> connection(m+1); for (int x = 0; x <= m; x++){ if (leads[x].size() == 0){ connection[x] = x; } else if (leads[x].size() == 1){ connection[x] = leads[x][0]; } else{ //construct binary tree connection[x] = construct(leads[x]); } //cerr << "leads " << x << '\n'; //for (auto y : leads[x]){ // cerr << y << ' '; //} //cerr << '\n'; } answer(connection, xLead, yLead); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 6784 KB | Output is correct |
3 | Correct | 17 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 13 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 6784 KB | Output is correct |
3 | Correct | 17 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 13 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 39 ms | 8144 KB | Output is correct |
9 | Correct | 43 ms | 9676 KB | Output is correct |
10 | Correct | 59 ms | 12496 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 24 ms | 6784 KB | Output is correct |
3 | Correct | 17 ms | 5724 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 13 ms | 3932 KB | Output is correct |
6 | Correct | 25 ms | 8536 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 39 ms | 8144 KB | Output is correct |
9 | Correct | 43 ms | 9676 KB | Output is correct |
10 | Correct | 59 ms | 12496 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Incorrect | 63 ms | 10908 KB | wrong motion |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |