結果
問題 | No.769 UNOシミュレータ |
ユーザー |
![]() |
提出日時 | 2018-12-19 01:27:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,195 bytes |
コンパイル時間 | 2,101 ms |
コンパイル使用メモリ | 195,360 KB |
最終ジャッジ日時 | 2025-01-06 19:39:20 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:53:23: warning: ‘id’ may be used uninitialized [-Wmaybe-uninitialized] 53 | cout << id + 1 << ' ' << a[id] << endl; | ^~~ main.cpp:16:18: note: ‘id’ was declared here 16 | int sum = 0, id; | ^~
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0; i < (N); i++) #define all(a) (a).begin(), (a).end() #define pb push_back using ll = long long; using i_i = tuple<int, int>; int main() { int N, M; cin >> N >> M; vector<int> a(N); int i = 0, d = 1; int sum = 0, id; string prev; while (M--) { string s; cin >> s; if (sum > 0 && s != prev) { a[i] -= sum; sum = 0; i = (i + d + N) % N; } id = i; // cout << id << ' ' << s << endl; if (s == "number") { a[i]++; i = (i + d + N) % N; } if (s == "drawtwo") { a[i]++; sum += 2; i = (i + d + N) % N; } if (s == "drawfour") { a[i]++; sum += 4; i = (i + d + N) % N; } if (s == "skip") { a[i]++; i = (i + d + N) % N; i = (i + d + N) % N; } if (s == "reverse") { a[i]++; d *= -1; i = (i + d + N) % N; } prev = s; } cout << id + 1 << ' ' << a[id] << endl; }