Submission #959499

#TimeUsernameProblemLanguageResultExecution timeMemory
959499idasWorm Worries (BOI18_worm)C++11
10 / 100
3014 ms600 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define sz(x) ((int)((x).size())) #define le(vec) vec[vec.size()-1] #define all(x) (x).begin(), (x).end() #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e6+10; int n, M, K, q, dp[N]; int qr(int i, int j, int k) { if(--q<0){ while(true); } cout << "? " << i << " " << j << " " << k << endl; int ret; cin >> ret; dp[i]=ret; return ret; } int get(int i) { if(i==0||i==n+1) return 0; if(dp[i]!=0) return dp[i]; return qr(i, 1, 1); } int main() { setIO(); cin >> n >> M >> K >> q; int l=1, r=n; while(l<r){ int m=(l+r+1)/2; int a=get(m-1), b=get(m); if(a>=b) r=m-1; else l=m; } cout << "! " << l << " " << 1 << " " << 1 << endl; }

Compilation message (stderr)

worm.cpp: In function 'void setIO(std::string)':
worm.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
worm.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...