結果

問題 No.282 おもりと天秤(2)
ユーザー chocorusk
提出日時 2019-03-31 08:17:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4,085 ms / 5,000 ms
コード長 1,587 bytes
コンパイル時間 1,226 ms
コンパイル使用メモリ 107,992 KB
実行使用メモリ 25,476 KB
平均クエリ数 440.67
最終ジャッジ日時 2024-07-17 02:11:53
合計ジャッジ時間 37,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
bool comp[501][501];
bool mycomp(int x, int y){
	return comp[x][y];
}
int main()
{
    int n; cin>>n;
	char c;
	for(int i=0; i<n; i++){
		cout<<"?";
		set<int> st;
		for(int j=0; j<n; j++){
			int l=(i-j+n)%n+1, r=(i+j)%n+1;
			if(l==r || st.find(l)!=st.end() || st.find(r)!=st.end()) cout<<" "<<0<<" "<<0;
			else{
				cout<<" "<<l<<" "<<r;
				st.insert(l);
				st.insert(r);
			}
		}
		cout<<endl;
		for(int j=0; j<n; j++){
			cin>>c;
			int l=(i-j+n)%n+1, r=(i+j)%n+1;
			if(l==r) continue;
			if(c=='<') comp[l][r]=1;
			else if(c=='>') comp[r][l]=1;
		}
		cout<<"?";
		st.clear();
		for(int j=0; j<n; j++){
			int l=(i-j+n)%n+1, r=(i+j+1)%n+1;
			if(l==r || st.find(l)!=st.end() || st.find(r)!=st.end()) cout<<" "<<0<<" "<<0;
			else{
				cout<<" "<<l<<" "<<r;
				st.insert(l);
				st.insert(r);
			}
		}
		cout<<endl;
		for(int j=0; j<n; j++){
			cin>>c;
			int l=(i-j+n)%n+1, r=(i+j+1)%n+1;
			if(l==r) continue;
			if(c=='<') comp[l][r]=1;
			else if(c=='>') comp[r][l]=1;
		}
	}
	int a[501];
	for(int i=0; i<n; i++) a[i]=i+1;
	sort(a, a+n, mycomp);
	cout<<"!";
	for(int i=0; i<n; i++) cout<<" "<<a[i];
	cout<<endl;
    return 0;
}
0