QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#467623 | #2670. Arranging shoes | james1BadCreeper | 0 | 3ms | 16392kb | C++17 | 1021b | 2024-07-08 16:58:02 | 2024-07-08 16:58:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int n;
int a[N];
vector<int> p[N];
bool vis[N];
struct Fenwick {
int C[N];
inline void add(int x, int k) { for (; x <= n; x += x & -x) C[x] += k; }
inline int sum(int x) { int r = 0; for (; x; x -= x & -x) r += C[x]; return r; }
inline int sum(int l, int r) { return sum(r) - sum(l - 1); }
} T;
long long count_swaps(vector<int> a) {
n = a.size();
a.push_back(0);
for (int i = n; i >= 1; --i) a[i] = a[i - 1];
for (int i = 1; i <= n; ++i) {
p[a[i] + n].push_back(i);
T.add(i, 1);
}
long long ans = 0;
for (int i = n; i >= 1; --i) if (!vis[i]) {
vis[i] = 1; p[a[i] + n].pop_back();
int res = p[n - a[i]].back(); p[n - a[i]].pop_back();
T.add(res, -1); T.add(i, -1);
vis[res] = 1; ans += T.sum(res, i) + (a[i] < 0);
// cerr << res << " " << i << "\n";
}
cout << ans << "\n";
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 16060kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
Unauthorized output
result:
wrong answer 1st lines differ - expected: '9ce55564-5404-428a-8d2e-0d809c85101e', found: 'Unauthorized output'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 0ms
memory: 14344kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -2 2 2
output:
Unauthorized output
result:
wrong answer 1st lines differ - expected: '9ce55564-5404-428a-8d2e-0d809c85101e', found: 'Unauthorized output'
Subtask #4:
score: 0
Wrong Answer
Test #74:
score: 0
Wrong Answer
time: 3ms
memory: 16392kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
Unauthorized output
result:
wrong answer 1st lines differ - expected: '9ce55564-5404-428a-8d2e-0d809c85101e', found: 'Unauthorized output'
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%