QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#351119 | #2645. Collapse | ltunjic | 0 | 33ms | 7880kb | C++14 | 1.0kb | 2024-03-11 16:07:47 | 2024-03-11 16:07:47 |
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, ++P[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]));
}
return ANS;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 2ms
memory: 4032kb
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 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3 5 3 5 ...
result:
wrong answer 7th lines differ - expected: '3', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 30
Accepted
time: 13ms
memory: 5624kb
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: 0
Accepted
time: 14ms
memory: 5524kb
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:
4 5 5 5 4 5 5 5 5 4 4 5 4 4 5 4 4 5 5 5 4 5 4 4 4 4 5 4 5 5 4 5 4 4 4 4 4 5 5 5 4 4 5 5 5 5 5 5 5 4 4 4 5 4 4 4 5 4 4 5 4 5 4 5 5 4 5 5 5 4 4 5 4 4 5 4 5 4 4 4 4 4 5 4 4 4 4 4 4 5 5 5 4 5 4 4 5 5 4 4 5 4 4 4 5 4 5 4 5 5 4 4 4 5 5 4 4 5 5 4 5 4 4 5 5 5 5 4 4 4 4 4 4 5 5 4 4 5 4 5 5 5 5 4 5 4 4 4 5 5 ...
result:
ok 100000 lines
Test #15:
score: -30
Wrong Answer
time: 33ms
memory: 7880kb
input:
10 100000 100000 0 4 5 0 2 0 1 2 0 0 1 8 1 5 4 0 8 6 0 2 3 0 1 7 1 7 1 1 8 6 0 6 0 0 9 1 0 2 1 0 0 7 1 7 0 1 8 1 1 2 1 1 1 9 0 9 4 1 6 0 1 4 9 1 3 2 0 2 6 0 5 4 0 7 5 0 1 9 0 6 0 1 1 9 1 0 6 0 3 8 1 6 2 1 7 5 1 4 5 1 8 3 0 1 5 0 1 6 0 1 9 1 6 1 1 9 1 1 5 1 0 7 2 1 2 7 0 8 9 1 9 8 0 9 4 0 9 1 0 4 1 1...
output:
-3 -9 0 9 3 -4 9 7 -4 5 -7 0 5 9 -5 -1 9 10 -1 -2 -10 1 -9 0 -2 -7 -3 -3 0 0 8 10 5 7 0 -3 7 -9 9 1 -1 -7 9 10 -7 -5 -9 2 8 3 -9 -1 -7 -4 3 8 9 0 -6 -8 3 8 -6 -3 6 -8 2 -5 2 3 -3 -1 5 4 5 4 -4 -9 -8 -4 -8 -3 2 -4 1 5 -2 -6 0 10 -7 -7 10 -8 8 -4 6 -1 0 -4 -10 6 2 -2 3 10 -7 1 -5 2 4 9 1 0 -5 -10 4 -9...
result:
wrong answer 1st lines differ - expected: '2', found: '-3'
Subtask #3:
score: 0
Wrong Answer
Test #28:
score: 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 0 4 1 5 1 4 4 4 1 4 0 0 3 4 0 4 3 5 4 3 4 4 4 5 3 5 5 3 1 3 4 5 1 3 4 3 4 3 5 0 5 4 5 0 4 1 5 2 4 5 4 3 1 3 3 3 1 4 5 4 5 4 4 0 3 4 3 3 0 3 0 3 2 0 4 4 4 5 3 2 4 5 4 4 5 3 2 1 5 2 5 4 3 0 5 4 4 5 3 3 4 4 3 5 4 0 4 1 0 4 1 3 4 1 5 5 4 4 1 1 3 3 4 0 0 5 5 4 ...
result:
wrong answer 2nd lines differ - expected: '2', found: '1'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%