Submission #289942

#TimeUsernameProblemLanguageResultExecution timeMemory
289942dandrozavrMechanical Doll (IOI18_doll)C++14
6 / 100
1095 ms137848 KiB
#include "doll.h" #include <vector> #include <iostream> #define pb push_back #define F first #define S second #define _ <<" "<< #define pii pair < int , int > using namespace std; void create_circuit (int m, vector < int > a) { int n = a.size(); a.pb(0); vector < int > c; vector < int > g[m + 1]; for (int i = 1; i <= n; ++i){ g[a[i - 1]].pb(a[i]); } g[0].pb(a[0]); int now = 1; vector < pii > swit; for (int i = 0; i <= m; ++i){ int sz = g[i].size(); // cout << i _ sz << endl; if (!sz){ c.pb(0); continue; } if (sz == 1){ c.pb(g[i][0]); } else { vector < int > all; for (int j = 0; j < sz; ++j){ all.pb(g[i][j]); } while(all.size() > 1){ vector < int > nall; for (int i = 0; i < all.size(); i += 2){ int Pr = swit.size() + 1; swit.pb({all[i], all[i + 1]}); nall.pb(-Pr); } if (all.size() % 2){ nall.pb(all.back()); } swap(nall, all); } c.pb(all[0]); } } // for (int i : c) cout << i << " "; // cout << endl; vector < int > X, Y; for (int i = 0; i < swit.size(); ++i){ X.pb(swit[i].F), Y.pb(swit[i].S); // cout << X.back() _ Y.back() << endl; } answer(c, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |                 for (int i = 0; i < all.size(); i += 2){
      |                                 ~~^~~~~~~~~~~~
doll.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < swit.size(); ++i){
      |                     ~~^~~~~~~~~~~~~
doll.cpp:21:9: warning: unused variable 'now' [-Wunused-variable]
   21 |     int now = 1;
      |         ^~~
#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...