답안 #1041699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041699 2024-08-02T07:11:52 Z vjudge1 Tenis (COI19_tenis) C++17
30 / 100
500 ms 2812 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
int n, q, p[N][3], ind[N][3];

bool check(int x){
    int it[3] = {n, n, n};
    int nit[3] = {ind[x][0], ind[x][1], ind[x][2]};
    int ite = 4 * n;
    while (ite > 0){
        for (int j = 0; j < 3; j ++){
            ite--;
            for (int i = it[j]; i >= nit[j]; i --){
                ite--;
                int ele = p[i][j];

                nit[0] = min(nit[0], ind[ele][0]);
                nit[1] = min(nit[1], ind[ele][1]);
                nit[2] = min(nit[2], ind[ele][2]);
            }
            it[j] = nit[j] - 1;
        }
    }

    return nit[0] == 1;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin >> n >> q;
    for (int j = 0; j < 3; j ++){
        for (int i = 1; i <= n; i ++){
            cin >> p[i][j];
            ind[p[i][j]][j] = i;
        }
    }

    for (int i = 0; i < q; i ++){
        int t;
        cin >> t;

        if (t == 1){
            int x;
            cin >> x;
            cout << (check(x) ? "DA\n" : "NE\n");
        }
        else{
            int j, a, b;
            cin >> j >> a >> b;
            j--;
            swap(p[ind[a][j]][j], p[ind[b][j]][j]);
            swap(ind[a][j], ind[b][j]);
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 15 ms 2652 KB Output is correct
14 Correct 15 ms 2652 KB Output is correct
15 Correct 16 ms 2652 KB Output is correct
16 Correct 18 ms 2652 KB Output is correct
17 Correct 20 ms 2652 KB Output is correct
18 Correct 17 ms 2812 KB Output is correct
19 Correct 19 ms 2652 KB Output is correct
20 Correct 13 ms 2652 KB Output is correct
21 Correct 19 ms 2652 KB Output is correct
22 Correct 17 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1044 ms 2788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 15 ms 2652 KB Output is correct
14 Correct 15 ms 2652 KB Output is correct
15 Correct 16 ms 2652 KB Output is correct
16 Correct 18 ms 2652 KB Output is correct
17 Correct 20 ms 2652 KB Output is correct
18 Correct 17 ms 2812 KB Output is correct
19 Correct 19 ms 2652 KB Output is correct
20 Correct 13 ms 2652 KB Output is correct
21 Correct 19 ms 2652 KB Output is correct
22 Correct 17 ms 2652 KB Output is correct
23 Execution timed out 1044 ms 2788 KB Time limit exceeded
24 Halted 0 ms 0 KB -