結果

問題 No.380 悪の台本
ユーザー LayCurseLayCurse
提出日時 2015-01-30 23:51:19
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,291 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 158,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:08:54
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 8 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:60:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   60 |   while(gets(in)){
      |         ~~~~^~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/c++/11/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
/usr/bin/ld: /tmp/ccMqrwIV.o: in function `main':
main.cpp:(.text.startup+0x29): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

char in[1000000];

int isSame(const char a[], const char b[], int len){
  int i;
  rep(i,len) if(a[i] != b[i]) return 0;
  return 1;
}

int isD(char a){
  if('a' <= a && a <= 'z') return 1;
  if('0' <= a && a <= '9') return 1;
  return 0;
}

int solve(void){
  int i, j, len;

  len = strlen(in);

  REP(i,5,len) if('A'<=in[i]&&in[i]<='Z') in[i] += 'a'-'A';

  if(isSame(in, "digi ", 5)){
    rep(i,4){
      if(isSame(in+len-3, "nyo", 3)) return 1;
      if(isD(in[len-1])) return 0;
      len--;
    }
  }else if(isSame(in, "petit ", 6)){
    rep(i,4){
      if(isSame(in+len-3, "nyu", 3)) return 1;
      if(isD(in[len-1])) return 0;
      len--;
    }
  }else if(isSame(in, "rabi ", 5)){
    REP(i,5,len) if(isD(in[i])) return 1;
  }else if(isSame(in, "gema ", 5)){
    rep(i,4){
      if(isSame(in+len-4, "gema", 4)) return 1;
      if(isD(in[len-1])) return 0;
      len--;
    }
  }else if(isSame(in, "piyo ", 5)){
    rep(i,4){
      if(isSame(in+len-3, "pyo", 3)) return 1;
      if(isD(in[len-1])) return 0;
      len--;
    }
  }

  return 0;
}

int main(){
  while(gets(in)){
    if(solve()) puts("CORRECT (maybe)");
    else        puts("WRONG!");
  }

  return 0;
}
0