Submission #222638

# Submission time Handle Problem Language Result Execution time Memory
222638 2020-04-13T13:40:21 Z kingfran1907 Tenis (COI19_tenis) C++14
51 / 100
500 ms 5756 KB
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5+10;

int n, q;
int niz[3][maxn];
int pos[3][maxn];
bool bio[maxn];
int las[3];
queue< int > qs;

void bfs() {
    memset(las, -1, sizeof las);
    memset(bio, false, sizeof bio);

    bio[niz[0][0]] = true; qs.push(niz[0][0]);
    bio[niz[1][0]] = true; qs.push(niz[1][0]);
    bio[niz[2][0]] = true; qs.push(niz[2][0]);

    while (!qs.empty()) {
        int x = qs.front();
        qs.pop();

        for (int i = 0; i < 3; i++) {
            for (int j = las[i] + 1; j <= pos[i][x]; j++) {
                if (!bio[niz[i][j]]) {
                    qs.push(niz[i][j]);
                    bio[niz[i][j]] = true;
                }
            }
            las[i] = max(las[i], pos[i][x]);
        }
    }
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", &niz[i][j]);

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < n; j++)
            pos[i][niz[i][j]] = j;

    bfs();
    for (int i = 0; i < q; i++) {
        int type;
        scanf("%d", &type);
        if (type == 1) {
            int x;
            scanf("%d", &x);
            if (bio[x]) printf("DA\n");
            else printf("NE\n");
        } else {
            int p, a, b;
            scanf("%d%d%d", &p, &a, &b); p--;
            int pa = pos[p][a], pb = pos[p][b];
            swap(niz[p][pa], niz[p][pb]);
            swap(pos[p][a], pos[p][b]);
            bfs();
        }
    }
    return 0;
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &niz[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~
tenis.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &type);
         ~~~~~^~~~~~~~~~~~~
tenis.cpp:53:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &x);
             ~~~~~^~~~~~~~~~
tenis.cpp:58:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d%d", &p, &a, &b); p--;
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 67 ms 4600 KB Output is correct
14 Correct 65 ms 4728 KB Output is correct
15 Correct 55 ms 4472 KB Output is correct
16 Correct 56 ms 4472 KB Output is correct
17 Correct 52 ms 4472 KB Output is correct
18 Correct 52 ms 4472 KB Output is correct
19 Correct 51 ms 4472 KB Output is correct
20 Correct 56 ms 4472 KB Output is correct
21 Correct 52 ms 4472 KB Output is correct
22 Correct 57 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 5624 KB Output is correct
2 Correct 85 ms 5496 KB Output is correct
3 Correct 85 ms 5624 KB Output is correct
4 Correct 86 ms 5624 KB Output is correct
5 Correct 88 ms 5496 KB Output is correct
6 Correct 93 ms 5624 KB Output is correct
7 Correct 85 ms 5496 KB Output is correct
8 Correct 86 ms 5624 KB Output is correct
9 Correct 89 ms 5756 KB Output is correct
10 Correct 84 ms 5496 KB Output is correct
11 Correct 85 ms 5496 KB Output is correct
12 Correct 87 ms 5624 KB Output is correct
13 Correct 88 ms 5624 KB Output is correct
14 Correct 87 ms 5624 KB Output is correct
15 Correct 83 ms 5496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 67 ms 4600 KB Output is correct
14 Correct 65 ms 4728 KB Output is correct
15 Correct 55 ms 4472 KB Output is correct
16 Correct 56 ms 4472 KB Output is correct
17 Correct 52 ms 4472 KB Output is correct
18 Correct 52 ms 4472 KB Output is correct
19 Correct 51 ms 4472 KB Output is correct
20 Correct 56 ms 4472 KB Output is correct
21 Correct 52 ms 4472 KB Output is correct
22 Correct 57 ms 4472 KB Output is correct
23 Correct 91 ms 5624 KB Output is correct
24 Correct 85 ms 5496 KB Output is correct
25 Correct 85 ms 5624 KB Output is correct
26 Correct 86 ms 5624 KB Output is correct
27 Correct 88 ms 5496 KB Output is correct
28 Correct 93 ms 5624 KB Output is correct
29 Correct 85 ms 5496 KB Output is correct
30 Correct 86 ms 5624 KB Output is correct
31 Correct 89 ms 5756 KB Output is correct
32 Correct 84 ms 5496 KB Output is correct
33 Correct 85 ms 5496 KB Output is correct
34 Correct 87 ms 5624 KB Output is correct
35 Correct 88 ms 5624 KB Output is correct
36 Correct 87 ms 5624 KB Output is correct
37 Correct 83 ms 5496 KB Output is correct
38 Execution timed out 1085 ms 5092 KB Time limit exceeded
39 Halted 0 ms 0 KB -