結果

問題 No.1306 Exactly 2 Digits
ユーザー ransewhaleransewhale
提出日時 2020-12-15 09:37:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,397 bytes
コンパイル時間 1,169 ms
コンパイル使用メモリ 97,720 KB
実行使用メモリ 25,452 KB
平均クエリ数 1236.78
最終ジャッジ日時 2024-07-17 10:09:27
合計ジャッジ時間 16,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,940 KB
testcase_01 AC 23 ms
24,940 KB
testcase_02 AC 23 ms
24,580 KB
testcase_03 AC 24 ms
24,836 KB
testcase_04 AC 24 ms
24,964 KB
testcase_05 AC 24 ms
25,220 KB
testcase_06 AC 23 ms
24,580 KB
testcase_07 AC 24 ms
24,580 KB
testcase_08 AC 24 ms
24,836 KB
testcase_09 AC 24 ms
24,964 KB
testcase_10 AC 24 ms
24,580 KB
testcase_11 WA -
testcase_12 AC 24 ms
24,964 KB
testcase_13 AC 24 ms
25,452 KB
testcase_14 WA -
testcase_15 AC 25 ms
25,312 KB
testcase_16 AC 25 ms
25,196 KB
testcase_17 AC 26 ms
25,196 KB
testcase_18 AC 24 ms
25,196 KB
testcase_19 AC 24 ms
25,196 KB
testcase_20 AC 24 ms
24,940 KB
testcase_21 AC 24 ms
24,940 KB
testcase_22 AC 24 ms
24,940 KB
testcase_23 AC 24 ms
24,940 KB
testcase_24 AC 24 ms
24,940 KB
testcase_25 AC 24 ms
25,196 KB
testcase_26 AC 25 ms
24,812 KB
testcase_27 AC 25 ms
25,196 KB
testcase_28 AC 24 ms
24,812 KB
testcase_29 AC 24 ms
24,556 KB
testcase_30 AC 25 ms
24,556 KB
testcase_31 AC 25 ms
24,940 KB
testcase_32 AC 26 ms
24,812 KB
testcase_33 AC 24 ms
24,556 KB
testcase_34 AC 25 ms
24,940 KB
testcase_35 AC 25 ms
24,812 KB
testcase_36 AC 26 ms
25,184 KB
testcase_37 AC 25 ms
25,184 KB
testcase_38 AC 25 ms
24,556 KB
testcase_39 AC 24 ms
24,556 KB
testcase_40 AC 24 ms
24,556 KB
testcase_41 AC 24 ms
24,556 KB
testcase_42 AC 24 ms
24,812 KB
testcase_43 AC 25 ms
24,812 KB
testcase_44 AC 26 ms
25,196 KB
testcase_45 AC 26 ms
24,812 KB
testcase_46 AC 26 ms
25,196 KB
testcase_47 AC 27 ms
24,940 KB
testcase_48 AC 29 ms
25,196 KB
testcase_49 AC 29 ms
24,940 KB
testcase_50 AC 31 ms
24,556 KB
testcase_51 AC 32 ms
24,588 KB
testcase_52 AC 34 ms
24,940 KB
testcase_53 AC 35 ms
24,940 KB
testcase_54 AC 34 ms
24,940 KB
testcase_55 AC 38 ms
24,800 KB
testcase_56 AC 39 ms
24,812 KB
testcase_57 AC 41 ms
24,940 KB
testcase_58 AC 42 ms
24,812 KB
testcase_59 AC 41 ms
24,940 KB
testcase_60 AC 48 ms
24,556 KB
testcase_61 AC 56 ms
24,556 KB
testcase_62 AC 51 ms
25,196 KB
testcase_63 AC 56 ms
24,556 KB
testcase_64 AC 54 ms
25,196 KB
testcase_65 AC 57 ms
25,452 KB
testcase_66 AC 64 ms
24,556 KB
testcase_67 AC 64 ms
24,812 KB
testcase_68 AC 64 ms
24,800 KB
testcase_69 AC 70 ms
25,324 KB
testcase_70 AC 70 ms
25,196 KB
testcase_71 AC 75 ms
25,452 KB
testcase_72 AC 75 ms
24,812 KB
testcase_73 AC 75 ms
24,800 KB
testcase_74 AC 85 ms
24,940 KB
testcase_75 AC 82 ms
25,452 KB
testcase_76 AC 94 ms
24,556 KB
testcase_77 AC 101 ms
24,556 KB
testcase_78 AC 108 ms
25,196 KB
testcase_79 AC 115 ms
24,940 KB
testcase_80 AC 122 ms
25,196 KB
testcase_81 AC 102 ms
24,940 KB
testcase_82 AC 125 ms
24,812 KB
testcase_83 AC 132 ms
24,428 KB
testcase_84 AC 139 ms
24,940 KB
testcase_85 AC 148 ms
24,812 KB
testcase_86 AC 121 ms
24,556 KB
testcase_87 AC 130 ms
24,812 KB
testcase_88 AC 156 ms
25,196 KB
testcase_89 AC 130 ms
24,556 KB
testcase_90 AC 121 ms
24,940 KB
testcase_91 AC 129 ms
24,556 KB
testcase_92 AC 119 ms
24,556 KB
testcase_93 AC 141 ms
24,940 KB
testcase_94 AC 117 ms
24,784 KB
testcase_95 AC 123 ms
24,940 KB
testcase_96 AC 114 ms
25,196 KB
testcase_97 AC 118 ms
24,812 KB
testcase_98 AC 111 ms
24,812 KB
testcase_99 AC 130 ms
24,940 KB
testcase_100 AC 127 ms
25,196 KB
testcase_101 AC 140 ms
24,812 KB
testcase_102 AC 116 ms
24,556 KB
testcase_103 AC 123 ms
24,940 KB
testcase_104 AC 124 ms
24,812 KB
testcase_105 AC 128 ms
24,940 KB
testcase_106 AC 113 ms
25,196 KB
testcase_107 AC 129 ms
25,196 KB
testcase_108 AC 129 ms
24,556 KB
testcase_109 AC 144 ms
25,196 KB
testcase_110 AC 117 ms
25,196 KB
testcase_111 AC 121 ms
24,812 KB
testcase_112 AC 109 ms
25,196 KB
testcase_113 AC 148 ms
24,812 KB
testcase_114 AC 152 ms
25,196 KB
testcase_115 AC 127 ms
25,196 KB
testcase_116 AC 153 ms
24,812 KB
testcase_117 AC 130 ms
24,812 KB
testcase_118 AC 141 ms
25,196 KB
testcase_119 AC 126 ms
24,940 KB
testcase_120 AC 113 ms
25,196 KB
testcase_121 AC 137 ms
24,556 KB
testcase_122 AC 133 ms
24,812 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;
	bool flag = false;
	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;
		}
	}
	if(z==1){
		flag = true;
		for(i=2; i<=m; ++i){
			if(s[i] == std::min(x-(n-1),y-(n-1)) && t[i] == std::max(x-(n-1),y-(n-1))){
				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;
		if(flag){
			p += (n-1);
			q += (n-1);
		}else{
			++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;
		}
		if(flag){
			p -= (n-1);
			q -= (n-1);
		}else{
			--p;
		}
		std::swap(p,q);
		if(flag){
			p += (n-1);
			q += (n-1);
		}else{
			++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;
		}
	}
	std::cout << "!";
	for(i=1; i<=m; ++i){
		std::cout << " " << ans[i];
	}
	std::cout << std::endl;
	return 0;
}
0