Submission #1026381

#TimeUsernameProblemLanguageResultExecution timeMemory
1026381ezzzayArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; const int N=3e5+5; int bit[N]; int a[N]; vector<int>v[N]; vector<int>ans; int n; int find(int idx){ int s=0; while(idx>0){ s+=bit[idx]; idx-= idx & -idx; } return s; } void update(int idx, int val){ while(idx<N){ bit[idx]+=val; idx+= idx & -idx; } } void fun(){ map<int,int>mp; for(int i=0;i<N;i++)bit[i]=0; for(int i=1;i<=n;i++){ mp[a[i]]; } int idx=1; for(auto it=mp.begin();it!=mp.end();it++){ it->ss = idx++; } for(int i=1;i<=n;i++){ a[i]=mp[a[i]]; } int s=0; for(int i=1;i<=n;i++){ update(a[i],1); s+=i-find(a[i]); } return s; } long long count_swaps(vector<int> s) { n=s.size(); vector<pair<int,int>>vc; for(int i=0;i<n;i++){ if(s[i]<0){ vc.pb({i,s[i]}); } else{ v[s[i]].pb(i); } } for(int i=0;i<3e5;i++){ reverse(v[i].begin(),v[i].end()); } sort(vc.begin(),vc.end()); for(int i=0;i<n/2;i++){ int h=vc[i].ss*-1; a[vc[i].ff+1]=i*2+1; // a[i*2+1]=vc[i].ff+1; a[v[h].back()+1]=i*2+2; //a[i*2+2]=v[h].back()+1; v[h].pop_back(); } return fun(); }

Compilation message (stderr)

shoes.cpp: In function 'void fun()':
shoes.cpp:32:13: error: 'struct std::pair<const int, int>' has no member named 'ss'
   32 |         it->ss = idx++;
      |             ^~
shoes.cpp:43:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   43 |     return s;
      |            ^
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:50:16: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   50 |             vc.pb({i,s[i]});
      |                ^~
shoes.cpp:53:21: error: 'class std::vector<int>' has no member named 'pb'
   53 |             v[s[i]].pb(i);
      |                     ^~
shoes.cpp:61:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ss'
   61 |         int h=vc[i].ss*-1;
      |                     ^~
shoes.cpp:62:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ff'
   62 |         a[vc[i].ff+1]=i*2+1;
      |                 ^~
shoes.cpp:68:15: error: void value not ignored as it ought to be
   68 |     return fun();
      |            ~~~^~