제출 #387449

#제출 시각아이디문제언어결과실행 시간메모리
387449ismoilovArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define rall(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fv(c) for(int (a) = (1); (a) <= (c); (a)++) #define fz(c) for(int (a) = (0); (a) < (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) #define pb push_back #define in insert #define ss second #define ff first struct ftree { vector <int> bit; ftree(int n){ bit = vector<int> (n+1); } void add(int k, int x){ k ++; while(k < bit.size()){ bit[k] += x; k += k & -k; } } int sum(int k) { int ans = 0; k ++; while(k){ ans += bit[k]; k -= k & -k; } return ans; } }; ll S(vector <int> &s) { ftree Ftree(s.size()); map<int, vector<int>> m; set<int> c; fp(i,0,s.size()){ c.in(i); m[s[i]].pb(i); Ftree.add(i, 1); } ll ans = 0; while(!c.empty()){ int x = *c.begin(); c.erase(c.begin()); m[s[x]].erase(m[s[x]].begin()); int y = *m[-s[x]].begin(); m[-s[x]].erase(m[-s[x]].begin()); Ftree.add(x, -1); Ftree.add(y, -1); c.erase(y); int g = Ftree.sum(y); if(s[x] > 0) g ++; ans += g; } return ans; } int main() { IOS; int n; cin >> n; vector <int> c(2*n); fp(i,0,2*n) cin >> c[i]; cout << S(c); /*int t; cin >> t; while(t--) S();*/ }

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

shoes.cpp: In member function 'void ftree::add(int, int)':
shoes.cpp:28:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   while(k < bit.size()){
      |         ~~^~~~~~~~~~~~
shoes.cpp: In function 'll S(std::vector<int>&)':
shoes.cpp:9:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
shoes.cpp:51:2: note: in expansion of macro 'fp'
   51 |  fp(i,0,s.size()){
      |  ^~
shoes.cpp:9:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                                      ~~~~^~~~~
shoes.cpp:51:2: note: in expansion of macro 'fp'
   51 |  fp(i,0,s.size()){
      |  ^~
shoes.cpp: In function 'int main()':
shoes.cpp:9:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
shoes.cpp:77:2: note: in expansion of macro 'fp'
   77 |  fp(i,0,2*n)
      |  ^~
/tmp/ccw9ycBe.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccJIY3QK.o:shoes.cpp:(.text.startup+0x0): first defined here
/tmp/ccw9ycBe.o: In function `main':
grader.cpp:(.text.startup+0x278): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status