제출 #171950

#제출 시각아이디문제언어결과실행 시간메모리
171950dndhkWorm Worries (BOI18_worm)C++14
10 / 100
35 ms588 KiB
#include <bits/stdc++.h> #define all(v) (v).begin(), (v).end() #define sortv(v) sort(all(v)) #define uniqv(v) (v).erase(unique(all(v)), (v).end()) #define pb push_back #define FI first #define SE second #define lb lower_bound #define ub upper_bound #define test 1 #define TEST if(test) using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; const int MOD = 1000000007; // 998244353 const int INF = 2e9; const ll INFLL = 1e18; const int MAX_N = 1; int N, M, K, Q; map<ll, int> mp; int ask(int x, int y, int z){ if(x<1 || x>N || y<1 || y>M || z<1 || z>K) return 0; ll t = (ll)x*(ll)(M+1)*(ll)(K+1)+(ll)y*(ll)(K+1)+(ll)z; if(mp[t]!=0){ return mp[t]; } printf("? %d %d %d\n", x, y, z); int ret; fflush(stdout); scanf("%d", &ret); mp[t] = ret; return ret; } void ans(int x, int y, int z){ printf("! %d %d %d\n", x, y, z); fflush(stdout); } void pro1(){ int s = 0, e = N+1, m; int mx = 0; while(s<e){ if(s==e-1){ int t1 = ask(s, 1, 1), t2 = ask(e, 1, 1); if(t1>t2){ ans(s, 1, 1); }else{ ans(e, 1, 1); } return; } m = (s+e)/2; int h = ask(m, 1, 1); if(h>mx){ int h2 = ask(m+1, 1, 1); if(h>h2){ e = m; mx = h; }else{ s = m+1; mx = h2; } }else{ if(ask(s, 1, 1)<ask(e, 1, 1)){ s = m; }else{ e = m; } } } ans(s, 1, 1); } vector<pii> vt; void pro2(){ pii s={1, 1}, e={N, M}; pii mx = {0, 0}; while(s.first!=e.first || s.second!=e.second){ if(s.second!=e.second){ while(!vt.empty()) vt.pop_back(); int m = (s.second + e.second)/2; for(int i=s.first; i<=e.first; i++){ vt.pb({ask(i, m, 1), i}); } sort(vt.begin(), vt.end()); if(vt.back().first>ask(mx.first, mx.second, 1)){ if(ask(vt.back().second, m-1, 1)>vt.back().first){ mx.first = vt.back().second; mx.second = m-1; e.second = m-1; }else if(ask(vt.back().second, m+1, 1)>vt.back().first){ mx.first = vt.back().second; mx.second = m+1; s.second = m+1; }else{ ans(vt.back().second, m, 1); return; } }else{ if(mx.second<m){ e.second = m-1; }else{ s.second = m+1; } } } if(s.first!=e.first){ while(!vt.empty()) vt.pop_back(); int m = (s.first+e.first)/2; for(int i=s.second; i<=e.second; i++){ vt.pb({ask(m, i, 1), i}); } sort(vt.begin(), vt.end()); if(vt.back().first>ask(mx.first, mx.second, 1)){ if(ask(m-1, vt.back().second, 1)>vt.back().first){ mx.first = m-1; mx.second = vt.back().second; e.first = m-1; }else if(ask(m+1, vt.back().second, 1)>vt.back().first){ mx.first = m+1; mx.second = vt.back().second; s.first = m+1; }else{ ans(m, vt.back().second, 1); return; } }else{ if(mx.first<m){ e.first = m-1; }else{ s.first = m+1; } } } } ans(s.first, s.second, 1); } int main(){ scanf("%d%d%d%d", &N, &M, &K, &Q); if(M==1 && K==1 && N==1000000){ pro1(); }else if(K==1){ pro2(); }else{ } return 0; }

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

worm.cpp: In function 'int ask(int, int, int)':
worm.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &ret);
  ~~~~~^~~~~~~~~~~~
worm.cpp: In function 'int main()':
worm.cpp:146:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &N, &M, &K, &Q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...