結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-04-16 20:50:18 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,736 bytes |
| コンパイル時間 | 939 ms |
| コンパイル使用メモリ | 31,104 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 08:23:04 |
| 合計ジャッジ時間 | 755 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 6 |
ソースコード
// yukicoder: No.380 悪の台本
// 2019.4.16 bal4u
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#if 0
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int ins(char *s) // 文字列の入力 スペース以下の文字で入力終了
{
int c;
char *p = s;
do {
c = gc();
if (c == EOF) return -1;
*s++ = c;
} while (c >= ' ');
*--s = 0;
return s - p;
}
void outs(char *s) { while (*s) pc(*s++); }
char *msg[2] = { "CORRECT (maybe)\n", "WRONG!\n" };
char s[120000];
char *name[5] = { "rabi", "digi", "petit", "gema", "piyo" };
int nlen[5] = { 4, 4, 5, 4, 4 };
char *tail[5] = { "\0", "nyo", "nyu", "gema", "pyo" };
int myCmp(char *s1, char *s2)
{
while (*s1 && *s2) {
if (isalpha(*s2) && tolower(*s2) == *s1) s1++, s2++;
else return 1;
}
return !(*s1 == 0 && *s2 == 0);
}
int main()
{
int i, w, id, f;
char *p, *q;
while ((w = ins(s)) >= 0) {
if (w < 6) goto err;
p = s; for (i = 0; i < 6 && *p != ' '; i++) p++;
if (i >= 6) goto err;
*p = 0; for (id = 0; id < 5; id++) {
if (strcmp(s, name[id]) == 0) break;
}
if (id >= 5) goto err;
if (id == 0) { // rabi
f = 0; while (*p) {
if (isalnum(*p)) f = 1;
p++;
}
if (!f) goto err;
} else {
if ((id == 3 && w - (nlen[id]+1) < 4) || w - (nlen[id] + 1) < 3) goto err;
q = s + w - 1;
for (i = 0; i < 3; i++) {
if (isalnum(*q)) break;
q--;
}
if (i >= 3 && !isalnum(*q)) goto err;
*(q+1) = 0;
w -= nlen[id]-1-i;
if (id == 3 && w < 4 || w < 3) goto err;
q -= (id == 3)? 3: 2;
if (q < p) goto err;
if (myCmp(tail[id], q)) goto err;
}
outs(msg[0]);
continue;
err: outs(msg[1]);
}
return 0;
}
bal4u