Submission #130276

#TimeUsernameProblemLanguageResultExecution timeMemory
130276khulegubMechanical Doll (IOI18_doll)C++14
6 / 100
467 ms30292 KiB
#include "doll.h" #include <bits/stdc++.h> #define mp make_pair #define xx first #define yy second #define pb push_back using namespace std; typedef pair<int, int> pii; /**********************/ /* YOU ARE INVITED TO */ /* */ /* SUFFER */ /* */ /* ######## */ /* # JOIN # */ /* ######## */ /* */ /**********************/ void create_circuit(int m, vector<int> a) { a.pb(0); int n = a.size(); vector<int> c(m + 1); vector<int> x, y; // map<int, unordered_set<int> > garalt; map< pair<int,int> , bool> memo; map<int, vector<int> > garalt; garalt[0].pb( a[0] ); for (int i = 0; i < n - 1; i++){ if (!memo[ mp(a[i], a[i + 1]) ]){ garalt[ a[i] ].pb( a[i + 1] ); memo[ mp(a[i], a[i + 1]) ] = 1; } } // for (int i = 0; i < n - 1; i++){ // } int s = 0; for (auto gang : garalt){ if(gang.yy.size() == 1){ c[gang.xx] = gang.yy[0]; } else{ // cout << gang.xx << ' '; int gangsz = gang.yy.size(); int gangcnt = 0; for (auto xaxa : gang.yy){ // cout << xaxa << ' '; if (gangcnt == 0){ x.pb(0); y.pb(0); c[gang.xx] = -(s + 1); x[s] = xaxa; y[s] = -(s + 2); s++; } else if (gangcnt == gangsz - 1){ y[s - 1] = xaxa; break; } else if (gangcnt == gangsz - 2){ x.pb(0); y.pb(0); x[s] = xaxa; s++; } else{ x.pb(0); y.pb(0); x[s] = xaxa; y[s] = -(s + 2); s++; } gangcnt++; } } // cout << gang.xx << ' ' << gang.yy.size() << '\n'; } // cout << y[0]; // cout << "\n#########################\n"; // for (auto X : y){ // cout << X << ' '; // } // answer(c, x, y); } // int main(){ // DRIVER - CHAN // create_circuit(9, {1, 3, 2, 1, 3, 4, 2, 1, 3}); // }
#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...