結果
| 問題 |
No.769 UNOシミュレータ
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2018-12-26 09:32:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,577 bytes |
| コンパイル時間 | 724 ms |
| コンパイル使用メモリ | 83,640 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 08:58:08 |
| 合計ジャッジ時間 | 2,012 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int readcard()’:
main.cpp:44:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
44 | scanf("%s", s);
| ~~~~~^~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:59:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
59 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 769.cc: No.769 UNOシミュレータ - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
enum { NUM, SKIP, REV, DRW2, DRW4 };
/* global variables */
char s[64];
int cns[MAX_N];
/* subroutines */
// "number", "drawtwo", "drawfour", "skip", "reverse"
int readcard() {
scanf("%s", s);
if (s[0] == 'n') return NUM;
if (s[0] == 's') return SKIP;
if (s[0] == 'r') return REV;
if (s[4] == 't') return DRW2;
return DRW4;
}
inline int next_card(int cid, int t, int n) { return (cid + n + t) % n; }
inline int prev_card(int cid, int t, int n) { return (cid + n - t) % n; }
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
int cid = 0, t = 1, d2 = 0, d4 = 0;
while (m--) {
int cd = readcard();
//printf("cd=%d\n", cd);
if ((d2 > 0 && cd != DRW2) || (d4 > 0 && cd != DRW4)) {
cns[cid] -= (d2 + d4);
d2 = d4 = 0;
cid = next_card(cid, t, n);
}
cns[cid]++;
if (cd == SKIP) cid = next_card(cid, t, n);
else if (cd == REV) t *= -1;
else if (cd == DRW2) d2 += 2;
else if (cd == DRW4) d4 += 4;
cid = next_card(cid, t, n);
}
cid = prev_card(cid, t, n);
printf("%d %d\n", cid + 1, cns[cid]);
return 0;
}
tnakao0123