結果
問題 |
No.2165 Let's Play Nim!
|
ユーザー |
|
提出日時 | 2023-03-28 01:25:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 1,618 bytes |
コンパイル時間 | 928 ms |
コンパイル使用メモリ | 91,900 KB |
最終ジャッジ日時 | 2025-02-11 18:45:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 38 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d", &as[i]); | ~~~~~^~~~~~~~~~~~~~ main.cpp:43:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d %d", &i, &k); i--; | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:64:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 64 | scanf("%d", &r); if (r==-1) break; | ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <map> #include <vector> #include <queue> #include <deque> #include <set> #include <stack> #include <algorithm> #include <array> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; class mypcmp { public: bool operator()(const int& a, const int& b) { return a<b; } }; int as[75000]; int main() { int n, i, m, x, j, k, d, v, r; scanf("%d", &n); set<int> bs[18]; m=0; for (i=0; i<n; i++) { scanf("%d", &as[i]); for (k=0; k<18; k++) if ((1<<k)&as[i]) bs[k].insert(i); m^=as[i]; } x=0; if (m==0) { x=1; printf("0\n"); } else printf("1\n"); fflush(stdout); while(1) { if (x) { // judge scanf("%d %d", &i, &k); i--; v=as[i]; m^=v; for (j=0; j<18; j++) if ((1<<j)&v) bs[j].erase(i); as[i]-=k; v=as[i]; m^=v; for (j=0; j<18; j++) if ((1<<j)&v) bs[j].insert(i); } else { // m should not be z for (j=17; j>=0; j--) if ((1<<j)&m) break; i=*bs[j].begin(); v=as[i]; for (j=0; j<18; j++) if ((1<<j)&v) bs[j].erase(i); as[i]^=m; d=v-as[i]; v=as[i]; for (j=0; j<18; j++) if ((1<<j)&v) bs[j].insert(i); m=0; printf("%d %d\n", i+1, d); fflush(stdout); } scanf("%d", &r); if (r==-1) break; x^=1; } return 0; }