Submission #802287

#TimeUsernameProblemLanguageResultExecution timeMemory
802287lollipopStations (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define ll long long #define pb push_back #define s second #define f first #define pf push_front #define inf 100000000000000000 #define bitebi __builtin_popcountll #define FOR( i , n ) for( int i = 0 ; i < n ; i ++ ) #define YES cout <<"YES\n" #define NO cout << "NO\n" #define debug cout << "Here Fine" << endl ; #define pr pair < int , int > #define fbo find_by_order // returns iterator #define ook order_of_key // returns strictly less numbers than key using namespace std ; //#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") using namespace __gnu_pbds; using namespace __gnu_cxx; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> const double Pi=acos(-1.0); const double EPS=1E-8; const int mod = 1000000007 ; const int mod1 = 998244353 ; const int NN = 2e5 + 10 ; mt19937 R(time(0)); map < int , int > ma , ma1 ; //#include "stations.h" vector < int > v[ NN ] ; int hh[ NN ] , timer = 0 ; pair < int , int > tt[ NN ] ; void dfs( int node , int parent , int h ){ hh[ node ] = h ; tt[ node ].f = timer ; timer ++ ; for( auto x : v[ node ] ){ if( x == parent ) continue ; dfs( x , node , h + 1 ) ; } tt[ node ].s = timer ; timer ++ ; } vector<int> label(int n, int k, vector<int> U, vector<int> V){ FOR( i , n ) v[ i ].clear() ; FOR( i , n - 1 ){ v[ U[ i ] ].pb( V[ i ] ) ; v[ V[ i ] ].pb( U[ i ] ) ; } dfs( 0 , -1 , 0 ) ; set < pair < int , int > > se ; FOR( i , n ){ se.insert( { tt[ i ].f , 0 } ) ; se.insert( { tt[ i ].s , 1 } ) ; } int cnt = 0 ; int mx = -1 , cur = 0 ; set < int > se1 , se2 ; FOR( i , 10 * n ){ se1.insert( cur ) ; se2.insert( cur + 1 ) ; cur += 2 ; } for( auto x : se ){ int nd ; if( x.s == 0 ){ nd = *se1.upper_bound( mx ) ; mx = nd ; } else{ nd = *se2.upper_bound( mx ) ; mx = nd ; } ma[ x.f ] = nd ; } vector < int > rt ; set < int > sis ; FOR( i , n ){ if( hh[ i ] % 2 == 0 ){ rt.pb( tt[ i ].f ) ; sis.insert( tt[ i ].f ) ; } else{ sis.insert( tt[ i ].s ) ; rt.pb( tt[ i ].s ) ; } } int cnt = 0 ; for( auto x : sis ){ ma[ x ] = cnt ; cnt ++ ; } FOR( i , n ) rt[ i ] = ma[ rt[ i ] ] ; return rt ; } int find_next_station(int s, int t, vector<int> c){ if( c.size() == 1 ) return c[ 0 ] ; int ss = c.size() ; if( s < c[ 0 ] ){ // anu gaqvs in-i // if( t % 2 == 0 ){ if( t < s ) return c[ ss - 1 ] ; if( t > c[ ss - 2 ] ) return c[ ss - 1 ] ; for( auto x : c ) if( x >= t ) return x ; // } // else{ // if( t < s ) return c[ ss - 1 ] ; // if( t > c[ ss - 2 ] ) return c[ ss - 1 ] ; // for( auto x : c ) if( x >= t ) return x ; // } } else{ // if( t % 2 == 0 ){ if( t > s ) return c[ 0 ] ; if( t < c[ 1 ] ) return c[ 0 ] ; FOR( i , ss ){ if( c[ i ] > t ) return c[ i - 1 ] ; } return c[ ss - 1 ] ; // } // else{ // if( t > s ) return c[ 0 ] ; // if( t < c[ 0 ] ) return c[ 0 ] ; // FOR( i , ss ){ // if( c[ i ] > t ) return c[ i - 1 ] ; // } // return c[ ss - 1 ] ; // } } } // static int max_label = 0; // static int r, n, k, q; // static std::vector<int> u, v, labels, answers; // static std::map<int, int> reverse_labels; // static std::vector<std::vector<int>> adjlist; // static int s, t, w; // static std::vector<int> c; // int main() { // assert(scanf("%d", &r) == 1); // for (int tc = 0; tc < r; tc++) { // assert(scanf("%d%d", &n, &k) == 2); // u.resize(n - 1); // v.resize(n - 1); // adjlist.clear(); // adjlist.resize(n); // for (int i = 0; i < n - 1; i++) { // assert(scanf("%d%d", &u[i], &v[i]) == 2); // adjlist[u[i]].push_back(v[i]); // adjlist[v[i]].push_back(u[i]); // } // labels = label(n, k, u, v); // if ((int)labels.size() != n) { // printf("Number of labels not equal to %d\n", n); // exit(0); // } // reverse_labels.clear(); // for (int i = 0; i < n; i++) { // if (labels[i] < 0 || labels[i] > k) { // printf("Label not in range 0 to %d\n", k); // exit(0); // } // if (reverse_labels.find(labels[i]) != reverse_labels.end()) { // printf("Labels not unique\n"); // exit(0); // } // reverse_labels[labels[i]] = i; // if (labels[i] > max_label) { // max_label = labels[i]; // } // } // assert(scanf("%d", &q) == 1); // for (int i = 0; i < q; i++) { // assert(scanf("%d%d%d", &s, &t, &w) == 3); // c.clear(); // for (int v : adjlist[s]) { // c.push_back(labels[v]); // } // std::sort(c.begin(), c.end()); // int answer = find_next_station(labels[s], labels[t], c); // if (!std::binary_search(c.begin(), c.end(), answer)) { // printf("Label %d returned by find_next_station not found in c\n", answer); // exit(0); // } // answers.push_back(reverse_labels[answer]); // } // } // printf("%d\n", max_label); // for (int index : answers) { // printf("%d\n", index); // } // exit(0); // }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:90:10: error: redeclaration of 'int cnt'
   90 |      int cnt = 0 ;
      |          ^~~
stations.cpp:59:10: note: 'int cnt' previously declared here
   59 |      int cnt = 0 ;
      |          ^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:133:1: warning: control reaches end of non-void function [-Wreturn-type]
  133 | }
      | ^