제출 #143592

#제출 시각아이디문제언어결과실행 시간메모리
143592kdh9949Arranging Shoes (IOI19_shoes)C++17
100 / 100
116 ms24852 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define x first #define y second #define pb push_back #define eb emplace_back #define ppb pop_back #define all(x) x.begin(),x.end() #define cppio ios_base::sync_with_stdio(0);cin.tie(0) using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 200005; vector<int> u[N], v[N], t[N]; vector<pii> w; int a[N]; struct BIT{ int d[N]; void u(int x){ for(; x < N; x += x & -x) d[x]++; } int g(int x){ int r = 0; for(; x; x -= x & -x) r += d[x]; return r; } int g(int s, int e){ return g(e) - g(s - 1); } } B; ll count_swaps(vector<int> s) { int n = s.size() / 2; for(int i = 0; i < 2 * n; i++) (s[i] < 0 ? u : v)[abs(s[i])].pb(i); for(int i = 1; i <= n; i++) for(int j = 0; j < u[i].size(); j++) w.pb(pii(u[i][j], v[i][j])); sort(all(w), [](pii x, pii y){ return x.x + x.y < y.x + y.y; }); for(int i = 0; i < n; i++){ a[w[i].x] = 2 * i + 1; a[w[i].y] = 2 * i + 2; } ll r = 0; for(int i = 0; i < 2 * n; i++){ r += B.g(a[i] + 1, 2 * n); B.u(a[i]); } return r; }

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

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:33:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i <= n; i++) for(int j = 0; j < u[i].size(); j++) w.pb(pii(u[i][j], v[i][j]));
                                             ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...