結果

問題 No.282 おもりと天秤(2)
ユーザー climpetclimpet
提出日時 2015-09-19 00:06:00
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 788 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 53,592 KB
実行使用メモリ 24,408 KB
平均クエリ数 615.21
最終ジャッジ日時 2023-09-23 06:07:14
合計ジャッジ時間 28,503 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,436 KB
testcase_01 AC 68 ms
23,364 KB
testcase_02 AC 32 ms
23,388 KB
testcase_03 AC 29 ms
23,388 KB
testcase_04 AC 29 ms
23,496 KB
testcase_05 AC 49 ms
23,400 KB
testcase_06 AC 78 ms
24,168 KB
testcase_07 AC 28 ms
24,180 KB
testcase_08 AC 82 ms
24,300 KB
testcase_09 AC 26 ms
24,312 KB
testcase_10 AC 2,527 ms
23,328 KB
testcase_11 TLE -
testcase_12 AC 2,874 ms
24,252 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 520 ms
24,336 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;

int n;
string rest;
char buf[3000];

int cmp(const void *p, const void *q){
	int a = *static_cast<const int*>(p);
	int b = *static_cast<const int*>(q);
	printf("? %d %d%s", a, b, rest.c_str());
	fflush(stdout);
	fgets(buf, 3000, stdin);
	if(buf[0] == '<'){ return -1; }
	if(buf[0] == '>'){ return 1; }
	return 0;
}

int main(){
	srand(time(0));

	scanf("%d%*c", &n);
	for(int i = 1; i < n; ++i){
		rest += " 0 0";
	}
	rest += '\n';
	vector<int> v(n);
	for(int i = 0; i < n; ++i){
		v[i] = i + 1;
	}
	random_shuffle(v.begin(), v.end());
	qsort(&v[0], n, sizeof(int), cmp);
	putchar('!');
	for(int i = 0; i < n; ++i){
		printf(" %d", v[i]);
	}
	puts("");
}
0