Submission #703205

#TimeUsernameProblemLanguageResultExecution timeMemory
703205Doncho_BonbonchoArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "shoes.h" typedef long long ll; const int MAX_N = 1e6 + 42; int p[MAX_N]; int last[MAX_N]; ll tree[MAX_N]; void add( int x, int v ){ // std::cerr<<" ! "<<x<<"\n"; while( x < MAX_N ){ tree[x] += v; x += x&(-x); } } int query( int x ){ int nas = 0; while( x ){ nas += tree[x]; x -= x&(-x); } return nas; } bool oke[MAX_N]; bool l[MAX_N]; long long count_swaps(std::vector<int> s) { ll nas = 0; int n = s.size(); for( int i=1 ; i<=n ; i++ ){ if( s[i-1] < 0 ) l[i] = true; int curr = abs( s[i-1] ); // std::cerr<<" ! "<<curr<<"\n"; // std::cerr<<last[curr]<<"\n"; if( last[curr] == 0 ) last[curr] = i; else{ p[i] = last[curr]; p[last[curr]] = i; last[curr] = 0; } add( i, 1 ); } /* for( int i=1 ; i<=n ; i++ ) std::cerr<<p[i]<<" "; std::cerr<<"\n"; */ for( int i=1 ; i<=n ; i++ ){ while( i<=n and oke[i] ) i++; if( i > n ) break; ll currNas = query( p[i] )-1; if( l[i] ){ // std::cerr<<"l -> -1 \n"; currNas --; } // std::cerr<<" ! "<<i<<" "<<p[i]<<" -> "<<currNas<<"\n\n"; nas += currNas; add( i, -1 ); add( p[i], -1 ); oke[i] = true; oke[p[i]] = true; } return nas; }#include <bits/stdc++.h> #include "shoes.h" typedef long long ll; const int MAX_N = 1e6 + 42; int p[MAX_N]; int last[MAX_N]; ll tree[MAX_N]; void add( int x, int v ){ // std::cerr<<" ! "<<x<<"\n"; while( x < MAX_N ){ tree[x] += v; x += x&(-x); } } int query( int x ){ int nas = 0; while( x ){ nas += tree[x]; x -= x&(-x); } return nas; } bool oke[MAX_N]; bool l[MAX_N]; long long count_swaps(std::vector<int> s) { ll nas = 0; int n = s.size(); for( int i=1 ; i<=n ; i++ ){ if( s[i-1] < 0 ) l[i] = true; int curr = abs( s[i-1] ); // std::cerr<<" ! "<<curr<<"\n"; // std::cerr<<last[curr]<<"\n"; if( last[curr] == 0 ) last[curr] = i; else{ p[i] = last[curr]; p[last[curr]] = i; last[curr] = 0; } add( i, 1 ); } /* for( int i=1 ; i<=n ; i++ ) std::cerr<<p[i]<<" "; std::cerr<<"\n"; */ for( int i=1 ; i<=n ; i++ ){ while( i<=n and oke[i] ) i++; if( i > n ) break; ll currNas = query( p[i] )-1; if( l[i] ){ // std::cerr<<"l -> -1 \n"; currNas --; } // std::cerr<<" ! "<<i<<" "<<p[i]<<" -> "<<currNas<<"\n\n"; nas += currNas; add( i, -1 ); add( p[i], -1 ); oke[i] = true; oke[p[i]] = true; } return nas; }

Compilation message (stderr)

shoes.cpp:80:2: error: stray '#' in program
   80 | }#include <bits/stdc++.h>
      |  ^
shoes.cpp:80:3: error: 'include' does not name a type
   80 | }#include <bits/stdc++.h>
      |   ^~~~~~~
shoes.cpp:85:11: error: redefinition of 'const int MAX_N'
   85 | const int MAX_N = 1e6 + 42;
      |           ^~~~~
shoes.cpp:6:11: note: 'const int MAX_N' previously defined here
    6 | const int MAX_N = 1e6 + 42;
      |           ^~~~~
shoes.cpp:87:5: error: redefinition of 'int p [1000042]'
   87 | int p[MAX_N];
      |     ^
shoes.cpp:8:5: note: 'int p [1000042]' previously declared here
    8 | int p[MAX_N];
      |     ^
shoes.cpp:88:5: error: redefinition of 'int last [1000042]'
   88 | int last[MAX_N];
      |     ^~~~
shoes.cpp:9:5: note: 'int last [1000042]' previously declared here
    9 | int last[MAX_N];
      |     ^~~~
shoes.cpp:90:4: error: redefinition of 'll tree [1000042]'
   90 | ll tree[MAX_N];
      |    ^~~~
shoes.cpp:11:4: note: 'll tree [1000042]' previously declared here
   11 | ll tree[MAX_N];
      |    ^~~~
shoes.cpp:92:6: error: redefinition of 'void add(int, int)'
   92 | void add( int x, int v ){
      |      ^~~
shoes.cpp:13:6: note: 'void add(int, int)' previously defined here
   13 | void add( int x, int v ){
      |      ^~~
shoes.cpp:100:5: error: redefinition of 'int query(int)'
  100 | int query( int x ){
      |     ^~~~~
shoes.cpp:21:5: note: 'int query(int)' previously defined here
   21 | int query( int x ){
      |     ^~~~~
shoes.cpp:109:6: error: redefinition of 'bool oke [1000042]'
  109 | bool oke[MAX_N];
      |      ^~~
shoes.cpp:30:6: note: 'bool oke [1000042]' previously declared here
   30 | bool oke[MAX_N];
      |      ^~~
shoes.cpp:110:6: error: redefinition of 'bool l [1000042]'
  110 | bool l[MAX_N];
      |      ^
shoes.cpp:31:6: note: 'bool l [1000042]' previously declared here
   31 | bool l[MAX_N];
      |      ^
shoes.cpp:112:11: error: redefinition of 'long long int count_swaps(std::vector<int>)'
  112 | long long count_swaps(std::vector<int> s) {
      |           ^~~~~~~~~~~
shoes.cpp:33:11: note: 'long long int count_swaps(std::vector<int>)' previously defined here
   33 | long long count_swaps(std::vector<int> s) {
      |           ^~~~~~~~~~~