QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#522416 | #5110. Splitstream | JooDdae | WA | 0ms | 3628kb | C++20 | 1.2kb | 2024-08-16 22:37:04 | 2024-08-16 22:37:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int m, n, q, s[100100], p[100100], r[100100];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> m >> n >> q;
s[1] = m;
for(int i=1;i<=n;i++) {
char c; cin >> c;
int x, y, z; cin >> x >> y >> z;
if(c == 'S') {
p[y] = p[z] = x;
r[y] = -1, r[z] = -2;
s[y] = (s[x]+1)/2;
s[z] = s[x]/2;
} else {
p[z] = x, r[z] = y;
s[z] = s[x]+s[y];
}
}
while(q--) {
int u, c; cin >> u >> c;
if(s[u] < c) {
cout << "none\n";
continue;
}
while(u != 1) {
int A = p[u], B = r[u];
if(B < 0) {
u = A;
c = c*2 - (B == -1);
} else {
if(c <= min(s[A], s[B])*2) {
u = c % 2 ? A : B;
c = (c+1)/2;
} else {
u = s[A] > s[B] ? A : B;
c = c - min(s[A], s[B]);
}
}
}
cout << c << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3628kb
input:
5 8 26 M 8 9 13 S 2 4 5 S 1 2 3 M 6 5 8 S 4 9 10 S 10 14 15 S 3 6 7 S 7 11 12 2 3 2 4 3 2 3 3 4 2 4 3 5 1 5 2 6 1 6 2 7 1 7 2 8 2 8 3 9 1 9 2 10 1 10 2 11 1 11 2 12 1 13 3 13 4 14 1 14 2 15 1
output:
5 none 4 none none none none none 2 none 4 none none none none none none none 4 none none none none none none none
result:
wrong answer 5th lines differ - expected: '5', found: 'none'