結果

問題 No.1306 Exactly 2 Digits
ユーザー HaaHaa
提出日時 2020-12-03 18:16:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 2,096 bytes
コンパイル時間 3,484 ms
コンパイル使用メモリ 179,544 KB
実行使用メモリ 24,384 KB
平均クエリ数 1237.78
最終ジャッジ日時 2023-09-24 08:27:00
合計ジャッジ時間 16,009 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,232 KB
testcase_01 AC 25 ms
23,988 KB
testcase_02 AC 25 ms
23,412 KB
testcase_03 AC 25 ms
23,988 KB
testcase_04 AC 25 ms
23,376 KB
testcase_05 AC 25 ms
23,412 KB
testcase_06 AC 25 ms
23,508 KB
testcase_07 AC 25 ms
23,964 KB
testcase_08 AC 25 ms
23,628 KB
testcase_09 AC 24 ms
23,976 KB
testcase_10 AC 24 ms
23,664 KB
testcase_11 AC 25 ms
23,628 KB
testcase_12 AC 25 ms
23,388 KB
testcase_13 AC 25 ms
23,484 KB
testcase_14 AC 26 ms
23,412 KB
testcase_15 AC 26 ms
24,324 KB
testcase_16 AC 25 ms
23,364 KB
testcase_17 AC 25 ms
23,988 KB
testcase_18 AC 25 ms
23,232 KB
testcase_19 AC 25 ms
24,276 KB
testcase_20 AC 25 ms
23,520 KB
testcase_21 AC 25 ms
24,264 KB
testcase_22 AC 25 ms
24,324 KB
testcase_23 AC 25 ms
23,976 KB
testcase_24 AC 25 ms
24,012 KB
testcase_25 AC 25 ms
23,640 KB
testcase_26 AC 25 ms
23,976 KB
testcase_27 AC 25 ms
23,664 KB
testcase_28 AC 26 ms
24,012 KB
testcase_29 AC 25 ms
23,640 KB
testcase_30 AC 25 ms
23,604 KB
testcase_31 AC 24 ms
24,312 KB
testcase_32 AC 26 ms
24,324 KB
testcase_33 AC 25 ms
23,376 KB
testcase_34 AC 26 ms
24,024 KB
testcase_35 AC 25 ms
23,604 KB
testcase_36 AC 25 ms
23,532 KB
testcase_37 AC 26 ms
24,312 KB
testcase_38 AC 26 ms
23,616 KB
testcase_39 AC 26 ms
23,820 KB
testcase_40 AC 26 ms
23,484 KB
testcase_41 AC 26 ms
23,604 KB
testcase_42 AC 27 ms
23,484 KB
testcase_43 AC 27 ms
23,376 KB
testcase_44 AC 27 ms
23,976 KB
testcase_45 AC 27 ms
23,652 KB
testcase_46 AC 29 ms
23,520 KB
testcase_47 AC 29 ms
24,300 KB
testcase_48 AC 31 ms
23,976 KB
testcase_49 AC 31 ms
23,388 KB
testcase_50 AC 32 ms
24,348 KB
testcase_51 AC 34 ms
23,484 KB
testcase_52 AC 35 ms
23,484 KB
testcase_53 AC 38 ms
23,376 KB
testcase_54 AC 36 ms
23,604 KB
testcase_55 AC 39 ms
23,232 KB
testcase_56 AC 39 ms
23,844 KB
testcase_57 AC 42 ms
23,496 KB
testcase_58 AC 44 ms
23,328 KB
testcase_59 AC 43 ms
23,832 KB
testcase_60 AC 51 ms
23,388 KB
testcase_61 AC 53 ms
24,324 KB
testcase_62 AC 52 ms
24,000 KB
testcase_63 AC 57 ms
24,024 KB
testcase_64 AC 55 ms
24,012 KB
testcase_65 AC 58 ms
24,312 KB
testcase_66 AC 62 ms
24,324 KB
testcase_67 AC 63 ms
23,796 KB
testcase_68 AC 64 ms
23,964 KB
testcase_69 AC 68 ms
23,664 KB
testcase_70 AC 68 ms
23,796 KB
testcase_71 AC 73 ms
24,384 KB
testcase_72 AC 73 ms
23,352 KB
testcase_73 AC 70 ms
24,024 KB
testcase_74 AC 82 ms
23,640 KB
testcase_75 AC 80 ms
24,036 KB
testcase_76 AC 88 ms
24,276 KB
testcase_77 AC 95 ms
23,628 KB
testcase_78 AC 101 ms
23,388 KB
testcase_79 AC 106 ms
24,024 KB
testcase_80 AC 114 ms
23,628 KB
testcase_81 AC 95 ms
23,376 KB
testcase_82 AC 117 ms
23,508 KB
testcase_83 AC 121 ms
23,364 KB
testcase_84 AC 129 ms
24,024 KB
testcase_85 AC 135 ms
23,376 KB
testcase_86 AC 115 ms
24,012 KB
testcase_87 AC 121 ms
23,520 KB
testcase_88 AC 145 ms
23,340 KB
testcase_89 AC 122 ms
23,844 KB
testcase_90 AC 109 ms
23,568 KB
testcase_91 AC 116 ms
23,376 KB
testcase_92 AC 109 ms
23,340 KB
testcase_93 AC 124 ms
23,988 KB
testcase_94 AC 108 ms
23,628 KB
testcase_95 AC 114 ms
23,592 KB
testcase_96 AC 103 ms
24,324 KB
testcase_97 AC 105 ms
24,348 KB
testcase_98 AC 102 ms
23,340 KB
testcase_99 AC 114 ms
23,340 KB
testcase_100 AC 119 ms
23,400 KB
testcase_101 AC 127 ms
23,376 KB
testcase_102 AC 107 ms
23,532 KB
testcase_103 AC 116 ms
23,376 KB
testcase_104 AC 111 ms
23,412 KB
testcase_105 AC 115 ms
23,796 KB
testcase_106 AC 105 ms
23,352 KB
testcase_107 AC 116 ms
24,000 KB
testcase_108 AC 111 ms
24,012 KB
testcase_109 AC 130 ms
23,520 KB
testcase_110 AC 109 ms
23,988 KB
testcase_111 AC 112 ms
23,376 KB
testcase_112 AC 100 ms
24,288 KB
testcase_113 AC 137 ms
23,508 KB
testcase_114 AC 135 ms
23,232 KB
testcase_115 AC 117 ms
23,412 KB
testcase_116 AC 143 ms
23,532 KB
testcase_117 AC 121 ms
24,024 KB
testcase_118 AC 127 ms
24,324 KB
testcase_119 AC 112 ms
24,024 KB
testcase_120 AC 102 ms
24,048 KB
testcase_121 AC 122 ms
23,340 KB
testcase_122 AC 118 ms
23,652 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:39:22: 警告: ‘mnp’ may be used uninitialized [-Wmaybe-uninitialized]
   39 |         int ff=-p[mnp].first+p[mxp].first+1;
      |                      ^
main.cpp:20:18: 備考: ‘mnp’ はここで定義されています
   20 |         int mxp, mnp;
      |                  ^~~
main.cpp:39:35: 警告: ‘mxp’ may be used uninitialized [-Wmaybe-uninitialized]
   39 |         int ff=-p[mnp].first+p[mxp].first+1;
      |                                   ^
main.cpp:20:13: 備考: ‘mxp’ はここで定義されています
   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==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}||c1==P{b,a+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}||c1==P{m-1-b,m-1-a}){
				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