Submission #1041542

#TimeUsernameProblemLanguageResultExecution timeMemory
1041542yanbMechanical Doll (IOI18_doll)C++14
6 / 100
38 ms14596 KiB
#include <bits/stdc++.h> using namespace std; //#define int long long //#define pii pair<long long, long long> void answer(vector<signed> C, vector<signed> X, vector<signed> Y); void create_circuit(int k, vector<int> a) { int n = a.size(); a.push_back(0); vector<vector<int>> g(k + 1); g[0].push_back(a[0]); for (int i = 0; i < n; i++) { g[a[i]].push_back(a[i + 1]); } vector<int> C(k + 1), X(4e5), Y(4e5); int nots = 0; for (int i = 0; i < k + 1; i++) { if (g[i].size() == 0) continue; if (g[i].size() == 1) { C[i] = g[i][0]; continue; } C[i] = -nots - 1; X[nots] = g[i][0]; Y[nots] = g[i][1]; nots++; for (int j = 1; j < (int) g[i].size() - 1; j++) { X[nots] = Y[nots - 1]; Y[nots - 1] = -nots - 1; Y[nots] = g[i][j + 1]; nots++; } } X.resize(nots); Y.resize(nots); answer(C, X, Y); } #ifdef ONLINE_JUDGE void answer(vector<signed> C, vector<signed> X, vector<signed> Y) { for (int x : C) cout << x << " "; cout << "\n"; for (int x : X) cout << x << " "; cout << "\n"; for (int x : Y) cout << x << " "; cout << "\n"; } int main() { create_circuit(4, {1, 2, 1, 3, 1, 4}); } #endif
#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...