제출 #965386

#제출 시각아이디문제언어결과실행 시간메모리
965386akacool445kArranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms504 KiB
#include <queue> #include <iostream> #include "shoes.h" using namespace std; int N; int bit[200001]; int query(int i) { int res = 0; while (i > 0) { res += bit[i]; i -= (i & -i); } return res; } void update(int i) { while (i <= N) { bit[i] = 0; i += (i & -i); } } long long count_swaps(vector<int> s) { long long n = s.size(); long long ans = 0; N = n; queue<int> a[n / 2 + 1], b[n / 2 + 1]; for (int i = 0; i < n; i++) { if (s[i] < 0) a[-s[i]].push(i); else b[s[i]].push(i); } vector<int> c(n, 1); for (int i = 0; i < n; i++) { if (c[i] == 0) continue; int ss = 0; int x = s[i]; int j = i; if (x < 0) { int y = -x; j = b[y].front(); b[y].pop(); a[y].pop(); } else { j = a[x].front(); a[x].pop(); b[x].pop(); } update(i + 1); update(j + 1); ans += query(j + 1); c[j] = 0; if (x > 0) ans++; } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:38:7: warning: unused variable 'ss' [-Wunused-variable]
   38 |   int ss = 0;
      |       ^~
#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...