結果

問題 No.1306 Exactly 2 Digits
ユーザー HaaHaa
提出日時 2020-12-03 17:49:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,064 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 181,288 KB
実行使用メモリ 25,964 KB
平均クエリ数 1237.78
最終ジャッジ日時 2024-07-17 08:50:33
合計ジャッジ時間 22,137 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,196 KB
testcase_01 AC 24 ms
24,812 KB
testcase_02 AC 24 ms
24,836 KB
testcase_03 AC 24 ms
24,964 KB
testcase_04 AC 23 ms
24,580 KB
testcase_05 AC 23 ms
24,580 KB
testcase_06 AC 24 ms
24,836 KB
testcase_07 AC 25 ms
24,836 KB
testcase_08 AC 24 ms
24,836 KB
testcase_09 AC 23 ms
24,580 KB
testcase_10 AC 25 ms
24,836 KB
testcase_11 WA -
testcase_12 AC 23 ms
25,220 KB
testcase_13 AC 23 ms
24,812 KB
testcase_14 WA -
testcase_15 AC 25 ms
24,556 KB
testcase_16 AC 25 ms
24,812 KB
testcase_17 AC 24 ms
25,196 KB
testcase_18 AC 25 ms
24,812 KB
testcase_19 AC 23 ms
24,812 KB
testcase_20 WA -
testcase_21 AC 24 ms
25,196 KB
testcase_22 AC 24 ms
24,812 KB
testcase_23 AC 26 ms
24,812 KB
testcase_24 AC 23 ms
24,812 KB
testcase_25 AC 24 ms
24,556 KB
testcase_26 WA -
testcase_27 AC 25 ms
25,508 KB
testcase_28 AC 25 ms
24,812 KB
testcase_29 AC 24 ms
24,556 KB
testcase_30 WA -
testcase_31 AC 23 ms
25,068 KB
testcase_32 WA -
testcase_33 AC 25 ms
25,196 KB
testcase_34 WA -
testcase_35 AC 23 ms
24,556 KB
testcase_36 AC 24 ms
25,196 KB
testcase_37 AC 24 ms
24,940 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 25 ms
24,812 KB
testcase_41 AC 25 ms
25,196 KB
testcase_42 AC 26 ms
25,196 KB
testcase_43 AC 25 ms
25,196 KB
testcase_44 AC 26 ms
24,812 KB
testcase_45 WA -
testcase_46 AC 27 ms
24,556 KB
testcase_47 AC 29 ms
25,196 KB
testcase_48 AC 30 ms
24,940 KB
testcase_49 WA -
testcase_50 AC 31 ms
24,940 KB
testcase_51 AC 35 ms
24,940 KB
testcase_52 AC 33 ms
25,580 KB
testcase_53 WA -
testcase_54 AC 35 ms
25,196 KB
testcase_55 WA -
testcase_56 AC 39 ms
24,940 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 41 ms
25,196 KB
testcase_60 WA -
testcase_61 AC 52 ms
24,940 KB
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 64 ms
24,812 KB
testcase_69 AC 68 ms
24,812 KB
testcase_70 AC 68 ms
24,812 KB
testcase_71 WA -
testcase_72 AC 70 ms
24,556 KB
testcase_73 AC 69 ms
24,556 KB
testcase_74 WA -
testcase_75 AC 78 ms
25,196 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 113 ms
25,196 KB
testcase_81 AC 96 ms
25,196 KB
testcase_82 AC 117 ms
25,180 KB
testcase_83 AC 120 ms
25,196 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 AC 115 ms
25,196 KB
testcase_87 WA -
testcase_88 AC 143 ms
25,196 KB
testcase_89 AC 123 ms
24,812 KB
testcase_90 AC 109 ms
25,196 KB
testcase_91 AC 119 ms
24,556 KB
testcase_92 AC 111 ms
24,812 KB
testcase_93 WA -
testcase_94 WA -
testcase_95 AC 115 ms
25,196 KB
testcase_96 AC 104 ms
24,556 KB
testcase_97 AC 104 ms
25,196 KB
testcase_98 AC 100 ms
24,812 KB
testcase_99 AC 117 ms
24,940 KB
testcase_100 WA -
testcase_101 WA -
testcase_102 AC 106 ms
24,812 KB
testcase_103 AC 116 ms
24,556 KB
testcase_104 WA -
testcase_105 AC 118 ms
24,812 KB
testcase_106 AC 104 ms
24,556 KB
testcase_107 AC 117 ms
25,196 KB
testcase_108 AC 108 ms
25,196 KB
testcase_109 WA -
testcase_110 WA -
testcase_111 WA -
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 AC 147 ms
24,940 KB
testcase_117 AC 123 ms
25,196 KB
testcase_118 AC 128 ms
25,196 KB
testcase_119 AC 114 ms
24,812 KB
testcase_120 WA -
testcase_121 WA -
testcase_122 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:39:22: warning: 'mnp' may be used uninitialized [-Wmaybe-uninitialized]
   39 |         int ff=-p[mnp].first+p[mxp].first+1;
      |                      ^
main.cpp:20:18: note: 'mnp' was declared here
   20 |         int mxp, mnp;
      |                  ^~~
main.cpp:39:35: warning: 'mxp' may be used uninitialized [-Wmaybe-uninitialized]
   39 |         int ff=-p[mnp].first+p[mxp].first+1;
      |                                   ^
main.cpp:20:13: note: 'mxp' was declared here
   20 |         int mxp, mnp;
      |             ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=1e18;

int main(){
	int n; cin >> n;
	int m=n; n=n*n-n;
	int a, b;
	vector<P> p(n), ans(n,{-1,-1});
	map<P,int> mp;
	vector<P> same;
	int mx=-1, mn=2*n;
	int mxp, mnp;
	REP(i,n){
		cout << "? " << i+1 << " " << 1 << endl;
		cin >> a >> b;
		p[i]={a,b};
		if(mp[p[i]]!=0)
			same.push_back({mp[p[i]]-1,i});
		else
			mp[p[i]]=i+1;
		if(a+b>mx){
			mx=a+b;
			mxp=i;
		}
		if(a+b<mn){
			mn=a+b;
			mnp=i;
		}
	}
	int ox, oy;
	int ff=-p[mnp].first+p[mxp].first+1;
	if(ff==m||ff==m-1){
		if(ff==m){
			ox=-p[mnp].first;
			oy=-p[mnp].second+1;
		}
		else{
			ox=-p[mnp].second;
			oy=-p[mnp].first+1;
		}
	}
	else{
		int sf=-p[mnp].second+p[mxp].first+1;
		if(sf==m){
			ox=-p[mnp].second;
			oy=-p[mnp].first+1;
		}
		else{
			ox=-p[mnp].first;
			oy=-p[mnp].second+1;
		}
	}
	ans[0]={ox,oy};
	ans[mnp]={0,1};
	ans[mxp]={m-1,m-1};
	if(ox+1!=oy){
		for(P s:same){
			cout << "? " << s.first+1 << " " << mnp+1 << endl;
			cin >> a >> b;
			P c1={ox+p[s.first].first,oy+p[s.first].second};
			P c2={ox+p[s.first].second,oy+p[s.first].first};
			if(c1==P{a,b+1}){
				ans[s.first]=c1;
				ans[s.second]=c2;
			}
			else{
				ans[s.first]=c2;
				ans[s.second]=c1;
			}
		}
	}
	else{
		for(P s:same){
			cout << "? " << mxp+1 << " " << s.first+1 << endl;
			cin >> a >> b;
			P c1={ox+p[s.first].first,oy+p[s.first].second};
			P c2={ox+p[s.first].second,oy+p[s.first].first};
			if(c1==P{m-1-a,m-1-b}){
				ans[s.first]=c1;
				ans[s.second]=c2;
			}
			else{
				ans[s.first]=c2;
				ans[s.second]=c1;
			}
		}
	}
	cout << "! ";
	REP(i,n){
		if(ans[i]==P{-1,-1}){
			P c1={ox+p[i].first,oy+p[i].second};
			if(c1.first>=0&&c1.first<m&&c1.second>=1&&c1.second<m)
				ans[i]=c1;
			else
				ans[i]={ox+p[i].second,oy+p[i].first};
		}
		cout << ans[i].first+ans[i].second*m << " ";
	}
	cout << endl;
	return 0;
}
0