제출 #147346

#제출 시각아이디문제언어결과실행 시간메모리
147346joylintpArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>#include "shoes.h" using namespace std; bool visit[200011] = {};long long n, ret = 0, bit[200011] = {}, s[200011], ans[200011];queue<int> Left[100006], Right[100006]; void bld(void){ for (int i = 2; i <= n + 10; i++) bit[i] = i - max(1, i - (i & -i));} long long sum(int x){ long long ret = 0; for (int i = x; i >= 1; i -= (i & -i)) ret += bit[i]; return ret;} void edt(int x, int k){ for (int i = x; i <= n; i += (i & -i)) bit[i] -= k;} long long count_swaps(vector<int> in){ n = in.size(); s[0] = 0; for (int i = 1; i <= n; i++) { s[i] = in[i - 1]; if (s[i] < 0) Left[-s[i]].push(i); else Right[s[i]].push(i); } bld(); int cnt = 0, pos, tar; for (int i = 1; i <= n; i++) { if (visit[i]) continue; tar = -abs(s[i]); pos = Left[-tar].front(), Left[-tar].pop(); ans[cnt++] = tar; visit[pos] = true; ret += sum(pos); edt(pos, 1); tar = -ans[cnt - 1]; pos = Right[tar].front(), Right[tar].pop(); ans[cnt++] = tar; visit[pos] = true; ret += sum(pos); edt(pos, 1); } return ret;}

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

shoes.cpp:1:24: warning: extra tokens at end of #include directive
 #include<bits/stdc++.h>#include "shoes.h" using namespace std; bool visit[200011] = {};long long n, ret = 0, bit[200011] = {}, s[200011], ans[200011];queue<int> Left[100006], Right[100006]; void bld(void){    for (int i = 2; i <= n + 10; i++)        bit[i] = i - max(1, i - (i & -i));} long long sum(int x){    long long ret = 0;    for (int i = x; i >= 1; i -= (i & -i))        ret += bit[i];    return ret;} void edt(int x, int k){    for (int i = x; i <= n; i += (i & -i))        bit[i] -= k;} long long count_swaps(vector<int> in){    n = in.size();    s[0] = 0;    for (int i = 1; i <= n; i++)    {        s[i] = in[i - 1];        if (s[i] < 0)            Left[-s[i]].push(i);        else            Right[s[i]].push(i);    }    bld();     int cnt = 0, pos, tar;    for (int i = 1; i <= n; i++)    {        if (visit[i])            continue;         tar = -abs(s[i]);        pos = Left[-tar].front(), Left[-tar].pop();        ans[cnt++] = tar;        visit[pos] = true;        ret += sum(pos);        edt(pos, 1);         tar = -ans[cnt - 1];        pos = Right[tar].front(), Right[tar].pop();        ans[cnt++] = tar;        visit[pos] = true;        ret += sum(pos);        edt(pos, 1);    }  return ret;}
                        ^
/tmp/cc3CgSnX.o: In function `main':
grader.cpp:(.text.startup+0x272): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status