結果

問題 No.282 おもりと天秤(2)
ユーザー IL_mstaIL_msta
提出日時 2015-09-18 23:53:15
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,076 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 88,716 KB
実行使用メモリ 24,228 KB
平均クエリ数 117.79
最終ジャッジ日時 2023-09-23 06:04:01
合計ジャッジ時間 11,510 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,544 KB
testcase_01 AC 74 ms
23,904 KB
testcase_02 AC 33 ms
24,228 KB
testcase_03 AC 31 ms
23,892 KB
testcase_04 AC 29 ms
24,060 KB
testcase_05 AC 51 ms
23,916 KB
testcase_06 AC 87 ms
24,132 KB
testcase_07 AC 30 ms
23,628 KB
testcase_08 AC 85 ms
23,388 KB
testcase_09 AC 26 ms
23,748 KB
testcase_10 AC 2,715 ms
7,852 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int N;
const int INFTY = (int)1e9+1;
vector<int> A(510);
vector<int> L(500);
vector<int> R(500);

bool check(int A,int B){
	// <=
	if( A != INFTY && B == INFTY ){
		return true;
	}else if( A == INFTY && B != INFTY ){
		return false;
	}else if( A== INFTY && B == INFTY ){
		return true;
	}
	cout << "? " << A << " " << B;
	for(int i=1;i<N;++i){
		cout << " 0 0";
	}
	cout << endl;
	string str,sub;
	cin >> str;
	for(int i=1;i<N;++i){
		cin >> sub;
	}
	if( str == "<" || str == "=" ){
		return true;
	}else{
		return false;
	}
	return false;
}
void merge(int left,int mid,int right){
	int n1 = mid - left;
	int n2 = right - mid;
	
	for(int i=0;i<n1; ++i){L[i] = A[left+i];}
	for(int i=0;i<n2; ++i){R[i] = A[mid+i];}
	
    L[n1] = INFTY;
    R[n2] = INFTY;
    int i,j;
    i = 0;
    j = 0;
    for(int k=left; k<right;++k){
        //if( L[i] <= R[j] ){
		if( check ( L[i] , R[j] ) ){//<=
            A[k] = L[i];
            ++i;
        }else{
            A[k] = R[j];
            ++j;
        }
    }
    return ;
}

void mergeSort(int left,int right){
    if( left+1 < right ){
        int mid = (left+right)/2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
    return;
}
void solve(){
	cin >> N;
	A.resize(N);
	rep(i,N){
		A[i] = i+1;
	}
	mergeSort(0,N);
	
	cout << "!";
	for(int i=0;i<N;++i){
		cout << " " << A[i];
	}
	cout << endl;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	
	//cpp
	solve();
	return 0;
}
0