結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
👑 testestest
|
| 提出日時 | 2016-03-10 01:11:29 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,722 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 19,712 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-13 13:57:35 |
| 合計ジャッジ時間 | 1,291 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 11 |
コンパイルメッセージ
main.c:3:1: warning: data definition has no type or storage class
3 | o1,o2,x1=14,d,m,n,t='x';
| ^~
main.c:3:1: warning: type defaults to ‘int’ in declaration of ‘o1’ [-Wimplicit-int]
main.c:3:4: warning: type defaults to ‘int’ in declaration of ‘o2’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^~
main.c:3:7: warning: type defaults to ‘int’ in declaration of ‘x1’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^~
main.c:3:13: warning: type defaults to ‘int’ in declaration of ‘d’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^
main.c:3:15: warning: type defaults to ‘int’ in declaration of ‘m’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^
main.c:3:17: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^
main.c:3:19: warning: type defaults to ‘int’ in declaration of ‘t’ [-Wimplicit-int]
3 | o1,o2,x1=14,d,m,n,t='x';
| ^
main.c:6:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
6 | main(){
| ^~~~
main.c: In function ‘main’:
main.c:7:5: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
7 | for(scanf("%d",&d);~t;t=n==10?t:n){
| ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
+++ |+#include <stdio.h>
1 | //自分で読んでも分からなくなること間違いなしっぽいのでメモ
main.c:7:5: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
7 | for(scanf("%d",&d);~t;t=n==10?t:n){
| ^~~~~
main.c:7:5: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:9:3: warning: implicit declaration of function ‘getchar’ [-Wimplicit-function-declaration]
9 | n=getchar();
| ^~~~~~~
main.c:9:3:
ソースコード
//自分で読んでも分からなくなること間違いなしっぽいのでメモ
#define max(a,b) (a>b?a:b)
o1,o2,x1=14,d,m,n,t='x';
//mはこれまでの最大値,tは今見てる1つ前の文字,nは今見てる文字
//o1x1o2と並んでいて、o2の切れ目でx1を潰す処理をする
main(){
for(scanf("%d",&d);~t;t=n==10?t:n){
//最後まで読んだ後も1回処理したいので終了条件はtで書く
n=getchar();
n==10?0://改行は読み飛ばす
n=='o'?o2++://oならo2カウンタを増やすだけ
//そうでない(==今の文字がxの)とき
t<n|n<0?//oからxに変わった直後か最後まで読んだなら
//1文字目がxのときにはここに来てほしくないので
//tの初期値は'x'(==120)以上でないと困る
m=x1>d?max(m,o2+d):max(m,o1+o2+x1)//o2が終わったと解釈してx1を潰してみる
//例えばd=6なら
//前者がoooxxxxxxxxooo→oooxxOOOOOOoooみたいなやつで
//後者がooxxxxooo→ooOOOOoooみたいなやつ
//後者にはxooxooxみたいにはみ出して潰せないパターンもあるが
//その場合はo1+x1+o2<dだから実際の最大値に関与しないので混ぜても問題ない
,o1=o2,o2=0,x1=1://値の更新
x1++;//そうじゃない(前もxで今もx)ならx1カウンタを増やすだけ
}
//末尾ループ内ではo2の前を潰すパターンしか見てないので
//最後の連休の後ろを潰すパターンを見る
m=!printf("%d",max(m,o1+d));
}
//これを圧縮して168B
//p,q,r=14,d,m;main(t,n){for(scanf("%d",&d);t=n+11?n:t;n+11?n+112?t>n|!n?m=r>d?d+q>m?d+q:m:m>(p+=q+r)?m:p,p=q,q=0,r=1:r++:q++:0)n=~getchar();m=!printf("%d",p+d>m?p+d:m);}
//nの初期値が-121以下になってないと死ぬ
testestest