제출 #1121026

#제출 시각아이디문제언어결과실행 시간메모리
112102612345678Zagrade (COI20_zagrade)C++17
0 / 100
2 ms592 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using namespace std; const int nx=1e5+5; int n, q, cnt, res[nx], x, jmp[nx], f[nx], qcnt=0; int query(int l, int r) { if (++qcnt>=q) cout<<1/0; cout<<"? "<<l<<' '<<r<<'\n'; fflush(stdout); cin>>x; return x; } void solve(int l, int r) { if (l<1||r>n||res[r]||f[r]) return; if (res[l]) return solve(jmp[l], r), void(); if (query(l, r)) res[l]=1, res[r]=2, jmp[r]=l-1, cnt+=2, solve(l-1, r+1); else f[r]=1; } int main() { cin>>n>>q; for (int i=1; i<=n; i++) { solve(i, i+1); } cnt=(n-cnt)/2; for (int i=1; i<=n; i++) { //cout<<jmp[i]<<' '; if (!res[i]&&cnt>0) cnt--, res[i]=2; else if (!res[i]) res[i]=1; } //cout<<'\n'; cout<<"! "; for (int i=1; i<=n; i++) cout<<((res[i]==1)?'(':')'); fflush(stdout); }

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

zagrade.cpp: In function 'int query(int, int)':
zagrade.cpp:14:27: warning: division by zero [-Wdiv-by-zero]
   14 |     if (++qcnt>=q) cout<<1/0;
      |                          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...