結果
| 問題 |
No.946 箱箱箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-09 07:09:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 103 ms / 2,000 ms |
| コード長 | 784 bytes |
| コンパイル時間 | 457 ms |
| コンパイル使用メモリ | 46,128 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 03:20:03 |
| 合計ジャッジ時間 | 5,592 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:14:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define PB push_back
constexpr int kN = int(1E5 + 10);
int a[kN], x[kN], ans[kN];
int main() {
int n, sz;
vector<int> tmp;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
x[0] = 0;
for (int i = 1; i <= n; i++) x[i] = x[i - 1] ^ a[i];
ans[n + 1] = 0;
for (int i = n; i >= 1; i--) {
tmp.clear();
for (int j = i; j <= n; j++) tmp.PB(x[j] ^ x[i - 1] ^ ans[j + 1]);
sort(tmp.begin(), tmp.end());
tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
sz = int(tmp.size());
if (tmp.back() == sz - 1) ans[i] = sz;
else for (int j = 0; j < sz; j++) if (tmp[j] != j) {
ans[i] = j;
break;
}
}
if (ans[1]) printf("Takahashi\n");
else printf("Takanashi\n");
}