結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー itezpaceitezpace
提出日時 2016-09-15 10:15:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,467 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 70,492 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 13:46:59
合計ジャッジ時間 1,862 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 1 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1 ms
6,940 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 AC 1 ms
6,940 KB
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 1 ms
6,940 KB
testcase_46 AC 1 ms
6,944 KB
testcase_47 AC 2 ms
6,944 KB
testcase_48 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:14: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
   23 |   for(int i; i<=s.size()+d; ++i){
      |              ^
main.cpp:33:14: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
   33 |   for(int i; i<=s.size()+d; ++i){
      |              ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
int main(){
  int d;
  cin>>d;
  string s,s2,s3,s4;
  cin>>s;
  cin>>s2;
  s+=s2;
  s3=s;
  s4=s;
  for(int i=0; i<d; ++i){
    s3.insert(s3.begin(),'o');
    s4.append(1,'o');
  }
  s3+='x';
  s4+='x';
  int m1=0;
  int a=0;
  for(int i; i<=s.size()+d; ++i){
    if(s3[i]=='o'){
      a+=1;
    } else {
      if(a>m1) m1=a;
      a=0;
    }
  }
  int m2=0;
  int b=0;
  for(int i; i<=s.size()+d; ++i){
    if(s4[i]=='o'){
      b+=1;
    } else {
      if(b>m2) m2=b;
      b=0;
    }
  }
  int c=0,d2,e;
  vector<tuple<int,int,int>> v;
  for(int i=0; i<s.size(); ++i){
    if(c==0 && s[i]=='x'){
      d2=i;
      c=1;
    } else if(c==1 && s[i]=='o'){
      e=i;
      c=0;
      if(e-d2<=d){
        tuple<int,int,int> t=make_tuple(e-d2,d2,e-1);
        v.push_back(t);
      }
    }
  }
  if(c==1){
    e=s.size();
    c=0;
    if(e-d2<=d){
      tuple<int,int,int> t=make_tuple(e-d2,d2,e-1);
      v.push_back(t);
    }
  }
  int m3=0;
  for(int i=0; i<v.size(); ++i){
    string s4=s;
    int f1=get<1>(v[i]);
    int f2=get<2>(v[i]);
    for(int i2=f1; i2<=f2; ++i2){
      s4[i2]='o';
    }
    int g=0;
    for(int i2=0; i2<s4.size(); ++i2){
      if(s4[i2]=='o'){
        g+=1;
      } else {
        if(g>m3) m3=g;
        g=0;
      }
    }
    if(g!=0){
      if(g>m3) m3=g;
      g=0;
    }
  }
  int m=max(m1,max(m2,m3));
  cout<<m<<endl;
  return 0;
}
0