QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356522#5110. SplitstreamTWTP_TCTF#WA 0ms3604kbC++142.0kb2024-03-17 22:03:142024-03-17 22:03:15

Judging History

你现在查看的是最新测评结果

  • [2024-03-17 22:03:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-03-17 22:03:14]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e5 + 9, MOD = 998244353;

pair<int, int> mergeNodes[N];
int firstChild[N], secondChild[N];
int len[N];

void doWork() {
    int m, n, q;
    cin >> m >> n >> q;
    len[1] = m;
    while (n--) {
        char c;
        int x, y, z;
        cin >> c >> x >> y >> z;
        if (c == 'M') {
            mergeNodes[z] = {x, y};
            len[z] = len[x] + len[y];
        } else {
            firstChild[y] = x;
            len[y] = (len[x] + 1) / 2;
            secondChild[z] = x;
            len[z] = len[x] / 2;
        }
    }
    while (q--) {
        int x, k;
        cin >> x >> k;
        bool ans = true;
        while (x > 1 && ans) {
            if (len[x] < k) {
                ans = false;
                break;
            }
            if (firstChild[x]) {
                k = 2 * k - 1;
                x = firstChild[x];
            } else if (secondChild[x]) {
                k = 2 * k;
                x = secondChild[x];
            } else {
                int a = mergeNodes[x].first, b = mergeNodes[x].second;
                int p = min(len[a], len[b]);
                if (k <= 2 * p) {
                    x = k % 2 ? a : b;
                    k = (k + 1) / 2;
//                    cout << "f " << a << " " << b << " " << k << "\n";
                } else if (len[a] > len[b]) {
                    k -= p;
                    x = a;
                } else {
                    k -= p;
                    x = b;
                }
            }
        }
        if (ans)
            cout << k << "\n";
        else
            cout << "none\n";
    }
}

int main() {

    IO
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

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'