답안 #611521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611521 2022-07-29T05:28:14 Z 반딧불(#8497) Tenis (COI19_tenis) C++17
30 / 100
500 ms 11768 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
int ranking[100002][3]; /// court j���� i�� ����ΰ�
int place[100002][3]; /// court j���� i���� �����ΰ�
bool visited[100002];
int tmin[3];

void solve(int x){
    if(visited[x]) return;
    visited[x] = 1;
    queue<int> que;
    for(int d=0; d<3; d++){
        int p = ranking[x][d];
        if(p >= tmin[d]) continue;
        for(int i=p+1; i<tmin[d]; i++) que.push(place[i][d]);
        tmin[d] = p;
    }
    while(!que.empty()) solve(que.front()), que.pop();
}

int main(){
    scanf("%d %d", &n, &q);
    for(int i=0; i<3; i++) for(int j=1; j<=n; j++){
        int x;
        scanf("%d", &x);
        ranking[x][i] = j;
        place[j][i] = x;
    }
    while(q--){
        int qt;
        scanf("%d", &qt);
        if(qt==1){
            int x;
            scanf("%d", &x);
            fill(visited+1, visited+n+1, 0);
            tmin[0] = tmin[1] = tmin[2] = n+1;
            solve(x);
            if(count(visited+1, visited+n+1, true) != n) printf("NE\n");
            else printf("DA\n");
        }
        else{
            int x, a, b;
            scanf("%d %d %d", &x, &a, &b);
            swap(place[ranking[a][x-1]][x-1], place[ranking[b][x-1]][x-1]);
            swap(ranking[a][x-1], ranking[b][x-1]);
        }
    }
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
tenis.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &qt);
      |         ~~~~~^~~~~~~~~~~
tenis.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |             scanf("%d", &x);
      |             ~~~~~^~~~~~~~~~
tenis.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |             scanf("%d %d %d", &x, &a, &b);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 57 ms 11768 KB Output is correct
14 Correct 51 ms 7660 KB Output is correct
15 Correct 49 ms 6340 KB Output is correct
16 Correct 68 ms 7860 KB Output is correct
17 Correct 88 ms 5700 KB Output is correct
18 Correct 74 ms 5696 KB Output is correct
19 Correct 76 ms 5640 KB Output is correct
20 Correct 39 ms 4284 KB Output is correct
21 Correct 68 ms 5688 KB Output is correct
22 Correct 65 ms 11248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 10916 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 57 ms 11768 KB Output is correct
14 Correct 51 ms 7660 KB Output is correct
15 Correct 49 ms 6340 KB Output is correct
16 Correct 68 ms 7860 KB Output is correct
17 Correct 88 ms 5700 KB Output is correct
18 Correct 74 ms 5696 KB Output is correct
19 Correct 76 ms 5640 KB Output is correct
20 Correct 39 ms 4284 KB Output is correct
21 Correct 68 ms 5688 KB Output is correct
22 Correct 65 ms 11248 KB Output is correct
23 Execution timed out 1066 ms 10916 KB Time limit exceeded
24 Halted 0 ms 0 KB -