Submission #812316

# Submission time Handle Problem Language Result Execution time Memory
812316 2023-08-07T08:21:50 Z MyCode Inside information (BOI21_servers) C++17
5 / 100
39 ms 3552 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int pos[n + 1], cur = 0;
    for (int i = 1; i <= n; i++)
        pos[i] = (int) 1e9;
    pos[1] = 0;
    for (int q = 0; q < n + k - 1; q++) {
        char t;
        cin >> t;
        if (t == 'S') {
            int a, b;
            cin >> a >> b;
            if (a != 1)swap(a, b);
            pos[b] = cur;
            cur++;
        } else if (t == 'Q') {
            int a, b;
            cin >> a >> b;
            if (a == 1) {
                if (pos[b] != (int) 1e9)
                    cout << "yes\n";
                else
                    cout << "no\n";
                continue;
            }
            if (b == 1) {
                if (pos[a] != (int) 1e9)
                    cout << "yes\n";
                else
                    cout << "no\n";
                continue;
            }
            if (pos[a] != (int)1e9 && pos[a] >= pos[b])
                cout << "yes\n";
            else
                cout << "no\n";
        } else {
            int d;
            cin >> d;
            if (d == 1) {
                cout << cur + 1 << "\n";
                continue;
            }
            if (pos[d] == (int) 1e9)cout << "1\n";
            else cout << 1 + cur - pos[d] << "\n";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 596 KB Output is correct
2 Correct 38 ms 1620 KB Output is correct
3 Correct 34 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 596 KB Output is correct
2 Correct 38 ms 1620 KB Output is correct
3 Correct 34 ms 1564 KB Output is correct
4 Correct 15 ms 596 KB Output is correct
5 Correct 39 ms 3380 KB Output is correct
6 Correct 28 ms 3520 KB Output is correct
7 Correct 29 ms 3552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 644 KB Output isn't correct
2 Halted 0 ms 0 KB -