結果

問題 No.282 おもりと天秤(2)
ユーザー pekempeypekempey
提出日時 2015-09-18 23:57:25
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,658 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 144,924 KB
実行使用メモリ 24,408 KB
平均クエリ数 240.04
最終ジャッジ日時 2023-09-23 06:05:19
合計ジャッジ時間 13,749 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int quicksort(int*, int, int)’:
main.cpp:56:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) rep2 (i, 0, a)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) repr2 (i, 0, a)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
#define rng(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;

#include <bits/stdc++.h>
#define rep(i, a) rep2 (i, 0, a)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) repr2 (i, 0, a)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
#define rng(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;

int n;
int C[555][555];
int a[555];

int comp(int i, int j) {
    cout << "?";
    cout << " " << a[i] + 1 << " " << a[j] + 1;
    rep (i, n - 1) cout << " 0 0";
    cout << endl;
    char str[2];
    scanf("%s", str);
    int res;
    if (str[0] == '<') res = -1;
    else if (str[1] == '=') res = 0;
    else res = 1;
    rep (i, n - 1) scanf("%s", str);
    return res;
}

int quicksort(int a[], int l, int r) {
	if (l < r) {
		int p = a[rand() % (r - l + 1) + l];
		int i = l - 1;
		int j = r + 1;
		while (true) {
			while (comp(a[++i], p) < 0);
			while (comp(a[--j], p) > 0);
			if (i >= j) break;
			swap(a[i], a[j]);
		}
		quicksort(a, l, i - 1);
		quicksort(a, j + 1, r);
	}
}

int main() {
    cin >> n;
    rep (i, n) a[i] = i;
    rep (i, n) a[i] = rand() % 100;
    quicksort(a, 0, n - 1);
    cout << "!";
    rep (i, n) cout << " " << a[i] + 1 << endl;
    return 0;
}
0