제출 #739241

#제출 시각아이디문제언어결과실행 시간메모리
739241nicolaevArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define mod                1000000007
#define ll                 long long 
#define all(v)             v.begin(), v.end()
#define fr(n)              for(ll i=0;i<n;++i)
#define ctz(x)             __builtin_ctzll(x)
#define clz(x)             __builtin_clzll(x)
#define pcount(x)          __builtin_popcountll(x)
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
// #define cin fin
// #define cout fout
// ifstream fin
// ofstream fout
//const ll maxn = 3e5 + 5;
//int f[maxn],nf[maxn],inv[maxn];
//const int M=998244353;
//void init(){
//inv[1]=1; for (int i=2;i<maxn;i++) inv[i]=M-1ll*(M/i)*inv[M%i]%M;
//f[0]=nf[0]=1; for (int i=1;i<maxn;i++) f[i]=1ll*f[i-1]*i%M,nf[i]=1ll*nf[i-1]*inv[i]%M;
//}
//int C(int x,int y){return 1ll*f[x]*nf[y]%M*nf[x-y]%M;}


ll count_swaps(ll s[]){
    ll n=sizeof(s)/8;
    vector< set<ll> > v(n+4);
    
    for(ll i=0; i<n; i++){
        if(s[i]<0){
            v[abs(s[i])+n/2].insert(i);
        }
        else v[s[i]].insert(i);
    }
    ll ans=0;
    for(ll i=0; i<n; i++){
        
        if(s[i]<0){
            if(v[abs(s[i])+n/2].empty()) continue;
            v[abs(s[i])+n/2].erase(i);
            set<ll> ::iterator it=v[abs(s[i])].begin();
            ans+=*it-i+1;
            v[abs(s[i])].erase(it);
        }
        else{
            if(v[s[i]].empty()) continue;
            v[s[i]].erase(i);
            set<ll> ::iterator it=v[n/2+s[i]].begin();
            ans+=*it-i;
            v[n/2+s[i]].erase(it);
        }
    }
    return ans;
    
}



// int main(){
//    ios_base::sync_with_stdio(false); cin.tie(NULL);
//    ll t;cin>>t;while(t--){solve();cout<<endl;}
// }

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

shoes.cpp: In function 'long long int count_swaps(long long int*)':
shoes.cpp:27:17: warning: 'sizeof' on array function parameter 's' will return size of 'long long int*' [-Wsizeof-array-argument]
   27 |     ll n=sizeof(s)/8;
      |                ~^~
shoes.cpp:26:19: note: declared here
   26 | ll count_swaps(ll s[]){
      |                   ^
/usr/bin/ld: /tmp/ccmjjMTC.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