結果

問題 No.282 おもりと天秤(2)
コンテスト
ユーザー chocorusk
提出日時 2019-03-31 08:17:25
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2,746 ms / 5,000 ms
+ 999µs
コード長 1,587 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 824 ms
コンパイル使用メモリ 142,604 KB
実行使用メモリ 9,772 KB
平均クエリ数 423.32
最終ジャッジ日時 2026-10-31 19:46:51
合計ジャッジ時間 25,575 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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