Submission #387450

#TimeUsernameProblemLanguageResultExecution timeMemory
387450ismoilovArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define rall(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fv(c) for(int (a) = (1); (a) <= (c); (a)++) #define fz(c) for(int (a) = (0); (a) < (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) #define pb push_back #define in insert #define ss second #define ff first struct ftree { vector <int> bit; ftree(int n){ bit = vector<int> (n+1); } void add(int k, int x){ k ++; while(k < bit.size()){ bit[k] += x; k += k & -k; } } int sum(int k) { int ans = 0; k ++; while(k){ ans += bit[k]; k -= k & -k; } return ans; } }; ll S(vector <int> &s) { ftree Ftree(s.size()); map<int, vector<int>> m; set<int> c; fp(i,0,s.size()){ c.in(i); m[s[i]].pb(i); Ftree.add(i, 1); } ll ans = 0; while(!c.empty()){ int x = *c.begin(); c.erase(c.begin()); m[s[x]].erase(m[s[x]].begin()); int y = *m[-s[x]].begin(); m[-s[x]].erase(m[-s[x]].begin()); Ftree.add(x, -1); Ftree.add(y, -1); c.erase(y); int g = Ftree.sum(y); if(s[x] > 0) g ++; ans += g; } return ans; }

Compilation message (stderr)

shoes.cpp: In member function 'void ftree::add(int, int)':
shoes.cpp:30:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(k < bit.size()){
      |         ~~^~~~~~~~~~~~
shoes.cpp: In function 'll S(std::vector<int>&)':
shoes.cpp:10:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
shoes.cpp:53:2: note: in expansion of macro 'fp'
   53 |  fp(i,0,s.size()){
      |  ^~
shoes.cpp:10:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                                      ~~~~^~~~~
shoes.cpp:53:2: note: in expansion of macro 'fp'
   53 |  fp(i,0,s.size()){
      |  ^~
/tmp/ccPpwXwm.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status