제출 #698602

#제출 시각아이디문제언어결과실행 시간메모리
698602feilinlpAlternating Heights (CCO22_day1problem1)C++17
0 / 25
1081 ms35532 KiB
#include <iostream> #include <algorithm> #include <utility> #include <cstring> #define f first #define s second using namespace std; bool comp( pair < pair <int, int> , int> a, pair < pair <int, int> , int> b) { if (a.f.f != b.f.f) return a.f.f < b.f.f; else return a.f.s < b.f.s; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k, q; cin >> n >> k >> q; int a[n], sign[k][k]; memset(sign, 0, sizeof(sign)); for (int i=0; i<n; i++) { cin >> a[i]; a[i]--; } // cout << __LINE__ << endl; pair < pair <int, int>, int> query[q]; int ans[q]; for (int i=0; i<q; i++) { // cout << __LINE__ << endl; ans[i]=-1; cin >> query[i].f.f >> query[i].f.s; query[i].s = i; } sort(query, query+q, comp); // cout << __LINE__ << endl; int left=0, right=0, pos=0; bool curr=true; while (pos<q) { // cout << __LINE__ << endl; int f=query[pos].f.f, s=query[pos].f.s; if (left != f) memset(sign, 0, sizeof(sign)); while (left < f) { // cout << __LINE__ << endl; left++; right = left; curr=true; } bool fail=false; while (query[pos].f.f == left) { int x=1; // cout << __LINE__ << endl; if (fail || a[right] == a[right+1] || sign[a[right]][a[right+1]]!=-x) { fail=true; // cout << __LINE__ << endl; ans[query[pos].s]=0; pos++; } else if (sign[a[right]][a[right+1]]==0 || sign[a[right]][a[right+1]]==x) { // cout << __LINE__ << endl; sign[a[right]][a[right+1]]=x; sign[a[right+1]][a[right]]=-x; } x=-x; // cout << __LINE__ << endl; } pos++; // cout << __LINE__ << endl; } for (int i=0; i<q; i++) { if (ans[i]) cout << "YES\n"; else cout << "NO\n"; } }

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

Main.cpp: In function 'int main()':
Main.cpp:6:11: warning: unused variable 'second' [-Wunused-variable]
    6 | #define s second
      |           ^~~~~~
Main.cpp:52:31: note: in expansion of macro 's'
   52 |         int f=query[pos].f.f, s=query[pos].f.s;
      |                               ^
Main.cpp:48:10: warning: variable 'curr' set but not used [-Wunused-but-set-variable]
   48 |     bool curr=true;
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...