QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#351111 | #2645. Collapse | ltunjic | 0 | 15ms | 5668kb | C++14 | 1.0kb | 2024-03-11 15:48:26 | 2024-03-11 15:48:26 |
Judging History
answer
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int LOG = 17;
const int N = 1 << LOG;
int F[N];
void add(int x, int val) {
for(; x < N; x += x & -x) F[x] += val;
}
int sum(int x) {
int ret = 0;
for(; x; x -= x & -x) ret += F[x];
return ret;
}
vi simulateCollapse(int n, vi T, vi X, vi Y, vi W, vi P) {
vi ANS(W.size());
vi I(W.size());
for(int i = 0; i < (int) T.size(); ++i) {
++X[i];
++Y[i];
if(X[i] > Y[i]) swap(X[i], Y[i]);
}
for(int i = 0; i < W.size(); ++i) I[i] = i;
sort(I.begin(), I.end(), [&W](int a, int b) { return W[a] < W[b]; });
int e = 0;
for(int j = 0, k = 0; k < W.size(); ++k) {
int i = I[k];
for(; j < W[i]; ++j) {
int x = T[j] ? -1 : 1;
e += x;
// printf("{%d, %d] += %d\n", X[j], Y[j], x);
add(X[j], x);
add(Y[j], -x);
}
// printf("ANS[%d] = %d (%d)\n", i, n - e + sum(P[i]), sum(P[i]));
ANS[i] = n - (e - sum(P[i] + 1));
}
return ANS;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 2ms
memory: 4092kb
input:
2 5000 5000 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1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 2 5 ...
result:
wrong answer 2nd lines differ - expected: '5', found: '4'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 30
Accepted
time: 13ms
memory: 5524kb
input:
2 1 100000 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 100000 lines
Test #14:
score: -30
Wrong Answer
time: 7ms
memory: 5668kb
input:
5 10 100000 0 3 2 1 2 3 0 2 1 0 2 3 0 0 3 1 3 2 1 1 2 0 2 4 0 0 2 0 4 0 2 2 0 2 7 2 1 2 8 2 0 2 0 2 6 2 0 2 2 2 2 2 7 2 5 2 8 2 0 2 9 2 2 2 7 2 6 2 0 2 8 2 1 2 3 2 2 2 9 2 9 2 1 2 9 2 6 2 1 2 3 2 1 2 3 2 3 2 5 2 8 2 3 2 0 2 7 2 7 2 8 2 9 2 1 2 1 2 0 2 1 2 1 2 0 2 7 2 9 2 2 2 5 2 6 2 2 2 9 2 9 2 0 2 ...
output:
5 5 5 5 5 5 5 4 5 5 5 5 4 5 5 4 5 5 4 5 5 5 4 5 4 4 5 4 4 5 4 5 4 4 4 5 4 5 5 5 5 4 5 5 5 5 5 5 5 4 5 4 4 5 4 4 5 5 5 5 5 5 4 5 5 4 5 5 5 4 4 5 4 4 5 5 5 5 5 4 5 5 5 4 4 4 5 5 4 5 5 4 4 4 4 4 5 5 4 5 5 4 4 4 5 5 5 4 4 4 5 4 4 4 5 4 4 4 4 4 5 4 4 4 4 5 5 4 4 4 5 5 4 5 5 5 4 5 4 5 5 5 5 4 5 4 5 5 5 4 ...
result:
wrong answer 1st lines differ - expected: '4', found: '5'
Subtask #3:
score: 0
Wrong Answer
Test #28:
score: 30
Accepted
time: 13ms
memory: 5540kb
input:
2 1 100000 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 100000 lines
Test #29:
score: -30
Wrong Answer
time: 15ms
memory: 5508kb
input:
5 7 100000 0 3 1 0 4 1 0 2 3 0 2 1 0 2 4 0 2 0 0 4 0 1 0 3 0 4 0 0 3 1 2 2 0 4 0 2 1 5 1 4 0 2 3 0 2 0 3 6 0 4 2 5 2 4 3 5 0 0 0 5 3 0 1 4 0 4 0 3 1 3 0 1 1 6 3 0 0 0 0 0 3 5 3 3 2 6 0 5 0 4 1 0 0 5 0 0 3 2 3 1 2 2 1 6 2 0 0 3 2 0 0 2 2 1 0 1 1 0 2 1 0 5 3 5 2 2 1 2 2 3 0 2 3 1 3 1 0 3 1 5 2 1 2 5 0...
output:
4 2 1 5 5 3 1 5 3 1 4 5 5 0 4 4 2 0 5 2 5 1 1 4 2 5 1 5 5 5 2 5 0 0 4 5 0 5 4 5 5 3 5 5 5 5 4 5 5 4 2 4 5 5 2 4 4 4 4 4 5 0 5 5 5 0 4 1 5 3 5 5 5 3 2 4 4 4 2 4 5 5 5 4 4 1 3 5 4 3 1 4 0 3 2 0 5 4 5 5 3 2 5 5 4 5 5 4 2 2 5 3 5 5 3 1 5 4 5 5 4 4 5 5 4 5 5 0 4 2 0 4 1 3 5 2 5 5 5 5 1 2 3 3 5 0 0 5 5 4 ...
result:
wrong answer 1st lines differ - expected: '3', found: '4'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%