結果
問題 | No.282 おもりと天秤(2) |
ユーザー |
![]() |
提出日時 | 2018-10-27 19:48:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,091 ms / 5,000 ms |
コード長 | 2,007 bytes |
コンパイル時間 | 2,693 ms |
コンパイル使用メモリ | 211,992 KB |
最終ジャッジ日時 | 2025-01-06 14:54:02 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>using namespace std;using i64 = int64_t;using vi = vector<i64>;using vvi = vector<vi>;int main() {int n;cin >> n;vvi res(n, vi(n));int N = n;deque<int> ord;for (int i = 1; i < n; i++) {ord.push_back(i);}if (n % 2) {ord.push_back(-1);n++;}reverse(ord.begin() + (n - 1) / 2, ord.end());for (int i = 0; i < n - 1; i++) {vvi match(n / 2, vi(2));match[0][0] = 0;int j = 1;for (int k: ord) {if (j < n / 2) {match[j][0] = k;} else {match[n - 1 - j][1] = k;}j++;}cout << "?";for (int i = 0; i < n / 2; i++) {if (match[i][0] == -1 || match[i][1] == -1) {cout << " 0 0";} else {cout << " " << match[i][0] + 1 << " " << match[i][1] + 1;}}for (int i = 0; i < N - n / 2; i++) {cout << " 0 0";}cout << endl;char ch;for (int i = 0; i < n / 2; i++) {cin >> ch;if (match[i][0] == -1 || match[i][1] == -1) {assert(ch == '=');} else {assert(ch != '=');if (ch == '>') {res[match[i][0]][match[i][1]] = 1;} else {res[match[i][1]][match[i][0]] = 1;}}}for (int i = 0; i < N - n / 2; i++) {cin >> ch;}ord.push_back(ord.front());ord.pop_front();}using ii = pair<int, int>;vector<ii> cnt;for (int i = 0; i < N; i++) {cnt.push_back(ii(accumulate(res[i].begin(), res[i].end(), 0), i));}sort(cnt.begin(), cnt.end());cout << "!";for (int i = 0; i < N; i++) {cout << " " << cnt[i].second + 1;}cout << endl;}