結果
| 問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-02 00:25:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 2,000 ms |
| コード長 | 1,405 bytes |
| コンパイル時間 | 5,206 ms |
| コンパイル使用メモリ | 313,812 KB |
| 実行使用メモリ | 25,592 KB |
| 平均クエリ数 | 1499.00 |
| 最終ジャッジ日時 | 2024-12-02 00:26:07 |
| 合計ジャッジ時間 | 18,831 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 57 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
const vector<int> dx{1,0,-1,0},dy{0,1,0,-1};
int main(){
int n,q;
cin >> n >> q;
queue<pair<pair<int,int>,pair<int,int>>> Q;
rep(i,1,n+1){
Q.push(mp(mp(i,n),mp(i,n)));
}
while(Q.size()>1){
auto [a,b]=Q.front();Q.pop();
auto [c,d]=Q.front();Q.pop();
pair<pair<int,int>,pair<int,int>> A;
int x;
if(a==b && c==d){
cout << "? " << a.first << " " << a.second << " " << c.first << " " << c.second << "\n";
cin >> x;
if(x==1)A=mp(a,c);
else A=mp(c,a);
Q.push(A);
continue;
}
cout << "? " << a.first << " " << a.second << " " << c.first << " " << c.second << "\n";
cin >> x;
if(x==1)A.first=a;
else A.first=c;
cout << "? " << b.first << " " << b.second << " " << d.first << " " << d.second << "\n";
cin >> x;
if(x==1)A.second=d;
else A.second=b;
Q.push(A);
}
auto [A,B]=Q.front();
cout << "! " << A.first << " " << A.first << " " << B.first << " " << B.second;
}