제출 #117914

#제출 시각아이디문제언어결과실행 시간메모리
117914songcTenis (COI19_tenis)C++14
100 / 100
226 ms5784 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; int N, Q; int A[101010]; int B[101010]; int C[101010]; int cnt[404040]; bool T[404040]; void update(int id, int s, int e, int ts, int te, int v){ if (e < ts || te < s) return; if (ts <= s && e <= te) { cnt[id] += v; T[id] = (cnt[id] > 0) || (T[id*2] && T[id*2+1]); return; } int mid = (s+e)/2; update(id*2, s, mid, ts, te, v); update(id*2+1, mid+1, e, ts, te, v); T[id] = (cnt[id] > 0) || (T[id*2] && T[id*2+1]); } bool query(int id, int s, int e, int ts, int te){ if (e < ts || te < s || T[id]) return true; if (ts <= s && e <= te) return T[id]; int mid = (s+e)/2; return query(id*2, s, mid, ts, te) && query(id*2+1, mid+1, e, ts, te); } int main(){ int a, b, c; scanf("%d %d", &N, &Q); for (int i=1; i<=N; i++){scanf("%d", &a); A[a] = i;} for (int i=1; i<=N; i++){scanf("%d", &a); B[a] = i;} for (int i=1; i<=N; i++){scanf("%d", &a); C[a] = i;} for (int i=1; i<=N; i++) update(1, 1, N, min(A[i], min(B[i], C[i])), max(A[i], max(B[i], C[i]))-1, 1); while (Q--){ scanf("%d", &a); if (a == 1){ scanf("%d", &a); if (query(1, 1, N, 1, min(A[a], min(B[a], C[a]))-1)) puts("DA"); else puts("NE"); } else{ scanf("%d %d %d", &a, &b, &c); update(1, 1, N, min(A[b], min(B[b], C[b])), max(A[b], max(B[b], C[b]))-1, -1); update(1, 1, N, min(A[c], min(B[c], C[c])), max(A[c], max(B[c], C[c]))-1, -1); if (a == 1) swap(A[b], A[c]); if (a == 2) swap(B[b], B[c]); if (a == 3) swap(C[b], C[c]); update(1, 1, N, min(A[b], min(B[b], C[b])), max(A[b], max(B[b], C[b]))-1, 1); update(1, 1, N, min(A[c], min(B[c], C[c])), max(A[c], max(B[c], C[c]))-1, 1); } } return 0; }

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

tenis.cpp: In function 'int main()':
tenis.cpp:35: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:36:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=1; i<=N; i++){scanf("%d", &a); A[a] = i;}
                              ~~~~~^~~~~~~~~~
tenis.cpp:37:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=1; i<=N; i++){scanf("%d", &a); B[a] = i;}
                              ~~~~~^~~~~~~~~~
tenis.cpp:38:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=1; i<=N; i++){scanf("%d", &a); C[a] = i;}
                              ~~~~~^~~~~~~~~~
tenis.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
tenis.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a);
             ~~~~~^~~~~~~~~~
tenis.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d %d", &a, &b, &c);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...