結果
| 問題 |
No.282 おもりと天秤(2)
|
| コンテスト | |
| ユーザー |
anta
|
| 提出日時 | 2015-09-18 23:01:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,438 bytes |
| コンパイル時間 | 844 ms |
| コンパイル使用メモリ | 90,176 KB |
| 実行使用メモリ | 25,708 KB |
| 平均クエリ数 | 8.92 |
| 最終ジャッジ日時 | 2024-07-16 05:52:17 |
| 合計ジャッジ時間 | 7,926 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 6 RE * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:83:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
83 | scanf("%s", s);
| ~~~~~^~~~~~~~~
main.cpp:89:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
89 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
int partner(int n, int l, int p) {
if(p == 1) {
return n ^ (1 << (l-1));
}else {
int scale = 1 << (l - p), box = 1 << p;
int sn = n / scale - (n / scale / box) * box;
if(sn == 0 || sn == box - 1)
return n;
else if(sn % 2 == 0)
return n - scale;
else
return n + scale;
}
}
int main() {
int N;
while(cin >> N) {
vi perm(N);
iota(all(perm), 1);
int d = 0;
while((1 << d) < N) ++ d;
rer(l, 1, d) rer(p, 1, l) {
// rep(i, N) cerr << perm[i] << " "; cerr << endl;
vector<bool> vis(N, false);
vector<pii> wires;
rep(i, N) if(!vis[i]) {
int j = partner(i, l, p);
if(j != i) {
assert(!vis[j]);
wires.push_back(mp(i, j));
vis[i] = vis[j] = true;
}
}
each(i, wires) if(i->first > i->second)
swap(i->first, i->second);
printf("?");
each(i, wires)
printf(" %d %d", perm[i->first], perm[i->second]);
rep(i, N - (int)wires.size())
printf(" 0 0");
puts("");
fflush(stdout);
char s[2];
each(i, wires) {
scanf("%s", s);
assert(*s != '=');
if(*s == '>')
swap(perm[i->first], perm[i->second]);
}
rep(i, N - (int)wires.size())
scanf("%s", s);
}
printf("!");
rep(i, N)
printf(" %d", perm[i]);
puts("");
fflush(stdout);
}
return 0;
}
anta