Submission #486792

#TimeUsernameProblemLanguageResultExecution timeMemory
486792HaidaraArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define rep(i,x,n) for(int i=x;i<n;i++) #define FOR(i,n) rep(i,0,n) #define v(i) vector< i > #define ll long long using namespace std; const int inf=1LL<<62LL; const int mod=1e9+7; const int maxn=100200; ll count_swaps(ll a[]) { ll ans=0; set<int>posl[maxn],posr[maxn]; FOR(i,n) if(a[i]<0) posl[-a[i]].insert(i); else posr[a[i]].insert(i); v(bool)vis(maxn,0); FOR(i,n) { if(vis[i]) continue; if(a[i]>0) ans++; if(a[i]<0) a[i]*=-1; vis[*posr[a[i]].begin()]=1; vis[*posl[a[i]].begin()]=1; ans+=abs(*posr[a[i]].begin()-*posl[a[i]].begin()); posl[a[i]].erase(posl[a[i]].begin()); posr[a[i]].erase(posr[a[i]].begin()); } return ans; }

Compilation message (stderr)

shoes.cpp:7:18: warning: overflow in conversion from 'long long int' to 'int' changes value from '4611686018427387904' to '0' [-Woverflow]
    7 | const int inf=1LL<<62LL;
      |               ~~~^~~~~~
shoes.cpp: In function 'long long int count_swaps(long long int*)':
shoes.cpp:14:8: error: 'n' was not declared in this scope
   14 |  FOR(i,n)
      |        ^
shoes.cpp:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,x,n) for(int i=x;i<n;i++)
      |                                  ^
shoes.cpp:14:2: note: in expansion of macro 'FOR'
   14 |  FOR(i,n)
      |  ^~~
shoes.cpp:20:8: error: 'n' was not declared in this scope
   20 |  FOR(i,n)
      |        ^
shoes.cpp:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,x,n) for(int i=x;i<n;i++)
      |                                  ^
shoes.cpp:20:2: note: in expansion of macro 'FOR'
   20 |  FOR(i,n)
      |  ^~~