結果

問題 No.380 悪の台本
ユーザー LayCurseLayCurse
提出日時 2017-01-22 23:45:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,419 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 145,556 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-06 20:16:10
合計ジャッジ時間 1,985 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:16: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   while(gets(in)){
                ^
In file included from /usr/include/c++/8/cstdio:42,
                 from /usr/include/c++/8/x86_64-redhat-linux/bits/stdc++.h:46,
                 from main.cpp:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
main.cpp:65:16: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   while(gets(in)){
                ^
In file included from /usr/include/c++/8/cstdio:42,
                 from /usr/include/c++/8/x86_64-redhat-linux/bits/stdc++.h:46,
                 from main.cpp:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
/tmp/cc9HfXNV.o: In function `main':
main.cpp:(.text.startup+0xe): warning: 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) in[i] = ' ';
    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,5) in[i] = ' ';
    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,4) in[i] = ' ';
    rep(i,len) if(isD(in[i])) return 1;
  }else if(isSame(in, "gema ", 5)){
    rep(i,4) in[i] = ' ';
    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) in[i] = ' ';
    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