제출 #117586

#제출 시각아이디문제언어결과실행 시간메모리
117586BruteforcemanTenis (COI19_tenis)C++11
39 / 100
88 ms5624 KiB
#include "bits/stdc++.h" using namespace std; int N, Q; int a[4][100010]; int p[4][100010]; int opt() { int mx1 = 0; int mx2 = 0; for(int i = 1; i <= N; i++) { mx1 = max(mx1, a[2][i]); mx2 = max(mx2, a[3][i]); if(mx1 == mx2 && mx1 == i) { return i; } } return N + 1; } void update(int q, int x, int y) { if(q == 1) { update(2, x, y); update(3, x, y); swap(p[1][x], p[1][y]); } else { int f = p[q][x]; int g = p[q][y]; swap(a[q][f], a[q][g]); swap(p[q][x], p[q][y]); } // cout << endl; // for(int i = 2; i <= 3; i++) { // for(int j = 1; j <= N; j++) { // cout << a[i][j] << ' '; // } // cout << endl; // } } int main(int argc, char const *argv[]) { scanf("%d %d", &N, &Q); for(int i = 1; i <= 3; i++) { for(int j = 1; j <= N; j++) { scanf("%d", &a[i][j]); p[i][a[i][j]] = j; } } for(int i = 2; i <= 3; i++) { for(int j = 1; j <= N; j++) { a[i][j] = p[1][a[i][j]]; p[i][a[i][j]] = j; // cout << a[i][j] << ' '; } // cout << endl; } int first = opt(); for(int i = 1; i <= Q; i++) { int c; scanf("%d", &c); if(c == 1) { int x; scanf("%d", &x); if(p[1][x] <= first) printf("DA\n"); else printf("NE\n"); } else { int f, x, y; scanf("%d %d %d", &f, &x, &y); update(f, p[1][x], p[1][y]); first = opt(); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tenis.cpp: In function 'int main(int, const char**)':
tenis.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~
tenis.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
tenis.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &c);
   ~~~~~^~~~~~~~~~
tenis.cpp:64:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &x);
    ~~~~~^~~~~~~~~~
tenis.cpp:69:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d", &f, &x, &y);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...