結果
| 問題 | No.3737 Quiz Time |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-14 01:06:59 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 3,006 bytes |
| 記録 | |
| コンパイル時間 | 2,379 ms |
| コンパイル使用メモリ | 343,028 KB |
| 実行使用メモリ | 6,528 KB |
| 平均クエリ数 | 44.65 |
| 最終ジャッジ日時 | 2026-09-19 13:16:13 |
| 合計ジャッジ時間 | 6,783 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / <nil> |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 48 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:118:34: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
118 | swap(ans[i],ans[x]);
| ^
main.cpp:112:20: note: 'x' was declared here
112 | ll x,y;
| ^
In function 'void swapcol(long long int, long long int, std::vector<std::vector<long long int> >&)',
inlined from 'int main()' at main.cpp:119:10:
main.cpp:94:36: warning: 'y' may be used uninitialized [-Wmaybe-uninitialized]
94 | swap(a[i][x],a[i][y]);
| ^
main.cpp: In function 'int main()':
main.cpp:112:22: note: 'y' was declared here
112 | ll x,y;
| ^
ソースコード
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i=0;i<(ll)n;i++)
#define rrep(i,n) for (ll i=(n)-1;i>=(ll)0;i--)
#define loop(i,m,n) for(ll i=m;i<=(ll)n;i++)
#define rloop(i,m,n) for(ll i=m;i>=(ll)n;i--)
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vdbg(a) rep(ii,a.size()){cout<<a[ii]<<" ";}cout<<endl;
#define vpdbg(a) rep(ii,a.size()){cout<<"{"<<a[ii].first<<","<<a[ii].second<<"} ";}cout<<endl;
#define vvdbg(a) rep(ii,a.size()){rep(jj,a[ii].size()){cout<<a[ii][jj]<<" ";}cout<<endl;}
#define setdbg(a) for(const auto & ii:a){cout<<ii<<" ";}cout<<endl;
#define inf 4000000000000000000LL
#define mod 998244353LL
//#define mod 1000000007LL
#define eps 0.000000001
#define circlepi 3.14159265358979323846
random_device rnd;// 非決定的な乱数生成器
mt19937 mt(rnd());// メルセンヌ・ツイスタの32ビット版、引数は初期シード
//#include<boost/multiprecision/cpp_int.hpp>
//#define bbi boost::multiprecision::cpp_int
//#include<atcoder/lazysegtree>
//整数同士の累乗の計算をする。
ll power(ll A, ll B) {
ll result = 1;
for (ll i=0;i<B;i++){
result *= A;
}
return result;
}
// nのk乗をmodで割った余りを計算
ll power_mod(ll n, ll k){
n%=mod;
ll ans = 1;
while (k > 0){
if ((k&1) ==1)ans=(ans*n)%mod;
n=n*n%mod;
k >>= 1;
}
return ans;
}
//受け取った2次元文字の外側に、文字pをコーティングする。
vector<string> pad(vector<string> &s,char p){
ll h=s.size();
ll w=s[0].size();
vector<string> res(h+2,string(w+2,p));
rep(i,h)rep(j,w)res[i+1][j+1]=s[i][j];
return res;
}
// Union-Find
struct UnionFind {
vector<int> par, siz;
UnionFind(int n) : par(n, -1) , siz(n, 1) { }
// 根を求める
int root(int x) {
if (par[x] == -1) return x;
else return par[x] = root(par[x]);
}
// x と y が同じグループに属するかどうか (根が一致するかどうか)
bool issame(int x, int y) {
return root(x) == root(y);
}
// x を含むグループと y を含むグループとを併合する
bool unite(int x, int y) {
x = root(x), y = root(y);
if (x == y) return false;
if (siz[x] < siz[y]) swap(x, y);
par[y] = x;
siz[x] += siz[y];
return true;
}
// x を含むグループのサイズ
int size(int x) {
return siz[root(x)];
}
};
//グリッド問題等用
vl dx={1,0,-1,0};
vl dy={0,1,0,-1};
void swapcol(ll x,ll y,vvl & a){
rep(i,a.size()){
swap(a[i][x],a[i][y]);
}
}
//メイン
int main(){
ll p;
cin>>p;
vvl ans(p,vl(p));
ll num=0;
rep(i,p)rep(j,p){
num++;
ans[i][j]=num;
}
rep(i,p-1){
cout<<"? "<<i+1<<" "<<i+1<<endl;
ll aa;
cin>>aa;
ll x,y;
rep(r,p)rep(c,p){
if(ans[r][c]==aa){
x=r,y=c;
}
}
swap(ans[i],ans[x]);
swapcol(x,y,ans);
}
//転置チェック
cout<<"? "<<1<<" "<<2<<endl;
ll aa;
cin>>aa;
if(ans[0][1]!=aa){
rep(i,p)rep(j,i){
swap(ans[i][j],ans[j][i]);
}
}
cout<<"!"<<endl;
vvdbg(ans);
}