Submission #274999

# Submission time Handle Problem Language Result Execution time Memory
274999 2020-08-20T03:48:51 Z khangal Arranging Shoes (IOI19_shoes) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define po pop_back
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define BOOST ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18
#define MIN -1e18
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
#define read(x) scanf("%lld",&x);
#define print(x) printf("%lld ",x);
#define endl '\n';
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,ans,mid,mn,mx,T,sum,h1,h2,e[1234567],b[1234567],c[1234567],d[1<<20],k,i,j,l,r,h,a[1234567],w,x,y,z,res,par[1234567],cnt,sz[1234567];
bool used[1234567];
vl v[1234567],vec1;
char s1[1234567],s[1234567],ss[1234567];
vector<pl> vp[1234567];
bool ok;
map<ll,ll> mp;
ll c1[2234][2234],c2[1234][1234];
char ch[2234][2234];
vl vec;
ll dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int subtask3(vector<int> vv,vector<int> vec){
    vl v;
    int res=0;
    for(int i=0;i<vv.size();i+=2){
        if(vec[vv[i]]<0){
            res+=abs(vv[i+1]-vv[i]-1);
        }
        else{
            res+=abs(vv[i+1]-vv[i]);
        }
    }
    return res;
}
int count_swaps(vector<int> vec){
    n=vec.size();
    map<int,vector<int>> mp;
    for(int i=0;i<vec.size();i++){
        mp[abs(vec[i])].pb(i);
    }
    for(auto u:mp){
        ans+=subtask3(mp[u],vec);
    }
    return ans;
}
// int main(){
//     cin>>n;
//     vector<int> vec(n);
//     for(auto &u:vec)cin>>u;
//     cout<<count_swaps(vec);
// }

Compilation message

shoes.cpp: In function 'int subtask3(std::vector<int>, std::vector<int>)':
shoes.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=0;i<vv.size();i+=2){
      |                 ~^~~~~~~~~~
shoes.cpp: In function 'int count_swaps(std::vector<int>)':
shoes.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i=0;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
shoes.cpp:62:25: error: no match for 'operator[]' (operand types are 'std::map<int, std::vector<int> >' and 'std::pair<const int, std::vector<int> >')
   62 |         ans+=subtask3(mp[u],vec);
      |                         ^
In file included from /usr/include/c++/9/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:81,
                 from shoes.cpp:1:
/usr/include/c++/9/bits/stl_map.h:490:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = std::vector<int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]'
  490 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:490:34: note:   no known conversion for argument 1 from 'std::pair<const int, std::vector<int> >' to 'const key_type&' {aka 'const int&'}
  490 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_map.h:510:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int; _Tp = std::vector<int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]'
  510 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_map.h:510:29: note:   no known conversion for argument 1 from 'std::pair<const int, std::vector<int> >' to 'std::map<int, std::vector<int> >::key_type&&' {aka 'int&&'}
  510 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~