結果

問題 No.1306 Exactly 2 Digits
ユーザー ransewhaleransewhale
提出日時 2020-12-15 09:31:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,061 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 96,276 KB
実行使用メモリ 24,408 KB
平均クエリ数 1236.78
最終ジャッジ日時 2023-09-24 09:24:56
合計ジャッジ時間 17,135 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,640 KB
testcase_01 WA -
testcase_02 AC 25 ms
23,640 KB
testcase_03 WA -
testcase_04 AC 26 ms
23,388 KB
testcase_05 AC 25 ms
24,024 KB
testcase_06 AC 25 ms
24,252 KB
testcase_07 AC 25 ms
23,544 KB
testcase_08 AC 25 ms
23,628 KB
testcase_09 AC 25 ms
24,048 KB
testcase_10 AC 25 ms
23,376 KB
testcase_11 WA -
testcase_12 AC 25 ms
23,628 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 27 ms
23,520 KB
testcase_16 AC 26 ms
23,364 KB
testcase_17 WA -
testcase_18 AC 27 ms
24,000 KB
testcase_19 AC 26 ms
23,520 KB
testcase_20 AC 26 ms
23,628 KB
testcase_21 AC 27 ms
23,628 KB
testcase_22 AC 27 ms
23,376 KB
testcase_23 AC 25 ms
23,436 KB
testcase_24 AC 25 ms
23,532 KB
testcase_25 AC 26 ms
23,520 KB
testcase_26 AC 27 ms
23,544 KB
testcase_27 AC 27 ms
23,352 KB
testcase_28 AC 26 ms
23,844 KB
testcase_29 AC 26 ms
24,000 KB
testcase_30 AC 25 ms
24,036 KB
testcase_31 AC 26 ms
24,012 KB
testcase_32 WA -
testcase_33 AC 26 ms
24,216 KB
testcase_34 AC 26 ms
23,532 KB
testcase_35 AC 26 ms
23,520 KB
testcase_36 AC 26 ms
23,424 KB
testcase_37 AC 26 ms
24,000 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 26 ms
23,364 KB
testcase_41 AC 25 ms
24,060 KB
testcase_42 AC 27 ms
24,360 KB
testcase_43 AC 27 ms
24,012 KB
testcase_44 AC 27 ms
24,036 KB
testcase_45 AC 27 ms
23,652 KB
testcase_46 AC 28 ms
23,532 KB
testcase_47 AC 29 ms
23,556 KB
testcase_48 AC 30 ms
23,544 KB
testcase_49 AC 31 ms
24,012 KB
testcase_50 AC 32 ms
24,324 KB
testcase_51 AC 33 ms
24,012 KB
testcase_52 AC 35 ms
24,192 KB
testcase_53 AC 38 ms
24,396 KB
testcase_54 AC 35 ms
23,556 KB
testcase_55 AC 39 ms
23,796 KB
testcase_56 AC 41 ms
24,180 KB
testcase_57 AC 42 ms
23,844 KB
testcase_58 AC 45 ms
24,396 KB
testcase_59 AC 43 ms
23,844 KB
testcase_60 AC 52 ms
24,396 KB
testcase_61 AC 56 ms
23,376 KB
testcase_62 AC 55 ms
24,336 KB
testcase_63 AC 58 ms
23,388 KB
testcase_64 AC 56 ms
23,796 KB
testcase_65 AC 59 ms
23,652 KB
testcase_66 AC 65 ms
23,376 KB
testcase_67 AC 66 ms
23,712 KB
testcase_68 AC 66 ms
23,844 KB
testcase_69 AC 70 ms
24,000 KB
testcase_70 AC 72 ms
23,364 KB
testcase_71 AC 74 ms
23,664 KB
testcase_72 AC 75 ms
24,012 KB
testcase_73 AC 75 ms
23,424 KB
testcase_74 AC 88 ms
24,048 KB
testcase_75 AC 83 ms
24,000 KB
testcase_76 AC 96 ms
24,276 KB
testcase_77 AC 102 ms
23,628 KB
testcase_78 AC 109 ms
24,000 KB
testcase_79 AC 117 ms
24,012 KB
testcase_80 AC 123 ms
23,640 KB
testcase_81 AC 104 ms
23,352 KB
testcase_82 AC 128 ms
24,012 KB
testcase_83 AC 131 ms
23,388 KB
testcase_84 AC 142 ms
23,376 KB
testcase_85 AC 150 ms
24,324 KB
testcase_86 AC 125 ms
23,664 KB
testcase_87 AC 130 ms
23,424 KB
testcase_88 AC 158 ms
23,376 KB
testcase_89 AC 135 ms
23,532 KB
testcase_90 AC 123 ms
23,652 KB
testcase_91 AC 130 ms
23,388 KB
testcase_92 AC 121 ms
23,808 KB
testcase_93 AC 139 ms
23,376 KB
testcase_94 AC 119 ms
23,664 KB
testcase_95 AC 127 ms
23,796 KB
testcase_96 AC 116 ms
24,072 KB
testcase_97 AC 118 ms
23,364 KB
testcase_98 AC 111 ms
23,652 KB
testcase_99 AC 128 ms
23,652 KB
testcase_100 AC 130 ms
23,424 KB
testcase_101 AC 142 ms
23,844 KB
testcase_102 AC 118 ms
23,628 KB
testcase_103 AC 125 ms
23,628 KB
testcase_104 AC 126 ms
24,192 KB
testcase_105 AC 130 ms
24,000 KB
testcase_106 AC 118 ms
23,412 KB
testcase_107 AC 132 ms
23,388 KB
testcase_108 AC 124 ms
23,844 KB
testcase_109 AC 145 ms
23,796 KB
testcase_110 AC 120 ms
24,384 KB
testcase_111 AC 125 ms
24,036 KB
testcase_112 AC 112 ms
23,520 KB
testcase_113 AC 151 ms
23,376 KB
testcase_114 AC 151 ms
23,544 KB
testcase_115 AC 130 ms
24,372 KB
testcase_116 AC 156 ms
24,336 KB
testcase_117 AC 134 ms
23,796 KB
testcase_118 AC 143 ms
23,364 KB
testcase_119 AC 125 ms
23,640 KB
testcase_120 AC 115 ms
23,376 KB
testcase_121 AC 135 ms
23,652 KB
testcase_122 AC 133 ms
24,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::map<std::vector<int>, int > dic;
std::vector<int> v(100);
int ans[2525],s[2525],t[2525],x,y,n;
bool used[55][55];

bool check(int p, int q){
	return (1<=x-p && x-p <n && 0<=y-q && y-q < n && (!used[x-p][y-q])); 
}

int main(void){
	int i,j,p,q,m,z;
	std::cin >> n; m = n*n-n;
	for(x=1; x<n; ++x){
		for(y=0; y<n; ++y){
			std::fill(v.begin(),v.end(),0);
			for(i=1; i<n; ++i){
				for(j=0; j<n; ++j){
					p = x-i; q = y-j;
					++v[p+50]; ++v[q+50];
				}
			}
			v[50] -= 2;
			dic[v] = x*n+y;
		}
	}
	std::fill(v.begin(),v.end(),0);
	for(i=2; i<=m; ++i){
		std::cout << "? 1 " << i << std::endl;
		std::cin >> s[i] >> t[i];
		++v[s[i]+50]; ++v[t[i]+50];
	}
	ans[1] = dic[v];
	x = ans[1]/n; y = ans[1]%n;
	z = 1; used[x][y] = true;
	for(i=2; i<=m; ++i){
		if(s[i] == std::min(x-1,y) && t[i] == std::max(x-1,y)){
			z = i;
		}
	}
	for(i=2; i<=m; ++i){
		if(s[i] == t[i]){
			used[x-s[i]][y-t[i]] = true;
			ans[i] = (x-s[i])*n+(y-t[i]);
			continue;
		}
		if(!check(s[i],t[i])){
			used[x-t[i]][y-s[i]] = true;
			ans[i] = (x-t[i])*n+(y-s[i]);
			continue;
		}
		if(!check(t[i],s[i])){
			used[x-s[i]][y-t[i]] = true;
			ans[i] = (x-s[i])*n+(y-t[i]);
			continue;
		}
		std::cout << "? " << i << " " << z << std::endl;
		std::cin >> p >> q;
		++p;
		if(s[i] == std::min(x-p,y-q) && t[i] == std::max(x-p,y-q)){
			used[p][q] = true;
			ans[i] = p*n+q;
			continue;
		}
		--p; std::swap(p,q); ++p;
		if(s[i] == std::min(x-p,y-q) && t[i] == std::max(x-p,y-q)){
			used[p][q] = true;
			ans[i] = p*n+q;
			continue;
		}
		--p;
	}
	std::cout << "!";
	for(i=1; i<=m; ++i){
		std::cout << " " << ans[i];
	}
	std::cout << std::endl;
	return 0;
}
0