제출 #719164

#제출 시각아이디문제언어결과실행 시간메모리
719164AndrijaMArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using ll=long long; using namespace std; ll count_swaps(vector<ll> a) { ll n = a.size(); ll ans = 0; if(n<=1010) { bool vis[n]; memset(vis,0,sizeof vis); for(ll i=0;i<n;i++) { if(vis[i])continue; ll j=i+1; ll val=0; while(a[j]!=-a[i] || vis[j]) { if(!vis[j])val++; j++; } if(a[i]>0) { ans+=val+1; } else { ans+=val; } vis[i]=vis[j]=true; } } else { vector<int>v; for(ll idx=0;idx<a.size();idx++) { if(a[idx]<0) v.push_back(idx); } sort(v.begin(),v.end()); ll k=0; for(ll idx=0;idx<v.size();idx++) { ans+=abs(v[idx]-k); k+=2; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'll count_swaps(std::vector<long long int>)':
shoes.cpp:39:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(ll idx=0;idx<a.size();idx++)
      |                      ~~~^~~~~~~~~
shoes.cpp:46:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(ll idx=0;idx<v.size();idx++)
      |                      ~~~^~~~~~~~~
/usr/bin/ld: /tmp/ccMTnBna.o: in function `main':
grader.cpp:(.text.startup+0x29d): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status