結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー kohei2019kohei2019
提出日時 2021-09-23 23:26:57
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 11,731 bytes
コンパイル時間 3,242 ms
コンパイル使用メモリ 173,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 09:36:46
合計ジャッジ時間 4,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:294:9: warning: left operand of comma operator has no effect [-Wunused-value]
  294 |         a,b = b,a%b;
      |         ^
main.cpp:294:18: warning: expression result unused [-Wunused-value]
  294 |         a,b = b,a%b;
      |                 ~^~
2 warnings generated.

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define INF 100000000
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl
#define coutALL1D(x) for(const auto & y:x){cout << y << " ";} cout << endl;
#define coutALL2D(x) for (const auto & y:x){for (const auto & z:y){cout << z << " ";}cout << endl;}
#define coutALLn(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<endl;cout<<*--x.end()<<endl
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

struct UnionFind{
    vector<int> parents;
    vector<int> sizeg;
    int group_cnt,N;
    UnionFind(int n){
        N = n;
        group_cnt = N;
        rep(i,N) parents.push_back(i);
        rep(i,N) sizeg.push_back(1);
    } 
    int find(int x){
        if (x == parents[x]){
            return x;
        }
        else{
            parents[x] = find(parents[x]);
            return parents[x];
        }
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if (x > y){
            swap(x,y);
        }
        if (x == y){
            return;
        }
        sizeg[x] += sizeg[y];
        parents[y] = x;
        group_cnt -= 1;
    }
    int size(int x){
        return sizeg[find(x)];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
    int groupcount(){
        return group_cnt;
    }
};

struct SegTree{
    ll DEFAULT = 0;
    ll func(ll x, ll y){
        return x ^ y;
    }
    int N,K = 0,N2;
    vector<ll> dat;
    SegTree(vector<ll> ls){
        N = ls.size();
        while ((N-1) >> K){
            K += 1;
        }
        //K -= 1;
        N2 = 1 << K;
        rep(i,1<<(K+1)){
           dat.push_back(DEFAULT); 
        }
        rep(i,N){
            dat[N2+i] = ls[i];
        }
        for (int i=N2-1;i>0;i--){
            dat[i] = func(dat[i<<1],dat[i<<1|1]);
        }
    }
    ll leafval(int x){
        return dat[x+N2];
    }
    void update(int x,ll y){
        int i = x + N2;
        dat[i] = y;
        while (i > 0){
            i >>= 1;
            dat[i] = func(dat[i<<1],dat[i<<1|1]);
        }
    }
    ll query(int L,int R){
        L += N2;
        R += N2;
        ll vL = DEFAULT;
        ll vR = DEFAULT;
        while (L < R){
            if (L & 1){
                vL = func(vL,dat[L]);
                L += 1;
            }
            if (R & 1){
                R -= 1;
                vR = func(dat[R],vR);
            }
            L >>= 1;
            R >>= 1;
        }
        return func(vL,vR);
    }
};

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

vector<ll> vector_find_ll(vector<ll> vec,ll num){
    int N = vec.size();
    vector<ll> match_num;
    rep(i,N){
        if (vec[i] == num){
            match_num.push_back(i);
        }
    }
    return match_num;
}

ll maxvec(vector<ll> vec){
    ll ret = -INF64;
    int N = vec.size();
    rep(i,N){
        ret = max(ret,vec[i]);
    }
    return ret;
}

ll minvec(vector<ll> vec){
    ll ret = INF64;
    int N = vec.size();
    rep(i,N){
        ret = min(ret,vec[i]);
    }
    return ret;
}

ll sumvec(vector<ll> ls){
    ll v = 0;
    int N = ls.size();
    rep(i,N){
        v += ls[i];
    }
    return v;
}

vector<ll> valuesmap(map<ll,ll> mp){
    vector<ll> ret;
    for (const auto & [key,value] : mp){
        ret.push_back(value);
    }
    return ret;
}

vector<ll> keysmap(map<ll,ll> mp){
    vector<ll> ret;
    for (const auto & [key,value] : mp){
        ret.push_back(key);
    }
    return ret;
}

vector<ll> set_to_vec(set<ll> st){
    vector<ll> ret;
    for (const auto & s:st){
        ret.push_back(s);
    }
    return ret;
}

vector<string> set_to_vec(set<string> st){
    vector<string> ret;
    for (const auto & s:st){
        ret.push_back(s);
    }
    return ret;
}

set<string> vec_to_set(vector<string> vec){
    set<string> ret;
    for (const auto & s:vec){
        ret.insert(s);
    }
    return ret;
}

map<ll,ll> Counter(vector<ll> vec){
    map<ll,ll> ret;
    for (const auto & s:vec){
        ret[s] += 1;
    }
    return ret;
}

map<string,ll> Counter(vector<string> vec){
    map<string,ll> ret;
    for (const auto & s:vec){
        ret[s] += 1;
    }
    return ret;
}

ll bisect_left(vector<ll> &vec,ll arg){
    //sort済みvecを二分探索
    ll ok=0;
    ll ng=vec.size();
    ll mid;
    while (abs(ng-ok) > 1){
        mid = (ok+ng)/2;
        if (vec[mid] > arg){
            ng = mid;
        }
        else{
            ok = mid;
        }
    }
    return ok;
}

ll bisect_right(vector<ll> &vec,ll arg){
    //sort済みvecを二分探索
    ll ng=0;
    ll ok=vec.size();
    ll mid;
    while (abs(ok-ng) > 1){
        mid = (ok+ng)/2;
        if (vec[mid] > arg){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return ok;
}

set<ll> primeset(ll N){
    // N以下の素数を全部列挙
    vector<ll> lsx(N+1,1);
    FOR(i,2,ceil(pow(N,0.5)+1)){
        if (lsx[i] == 1){
            for(ll j=i;j<N/i+1;j++){
                lsx[j*i] = 0;
            }
        }
    }
    set<ll> ret;
    for (ll i=2;i < N+1; i++){
        if (lsx[i] == 1){
            ret.insert(i);
        }
    }
    return ret;
}

ll gcd(ll a,ll b){
    while (b != 0){
        a,b = b,a%b;
    }
    return a;
}

ll lmc(ll a, ll b){
    ll c = gcd(a,b);
    return a*b/c;
}

ll gcdvec(vector<ll> vec){
    ll ret=vec[0];
    for (const auto & v:vec){
        ret = gcd(ret,v);
    }
    return ret;
}

ll lmcvec(vector<ll> vec){
    ll ret=vec[0];
    for (const auto & v:vec){
        ret = lmc(ret,v);
    }
    return ret;
}

vector<vector<ll>> factorization(ll N){
    vector<vector<ll>> ret;
    ll temp = N;
    FOR(i,2,ceil(pow(N,0.5)+1)){
        if (temp%i==0){
            ll cnt = 0;
            while(temp%i==0){
                cnt += 1;
                temp /= i;
            }
            ret.push_back({i,cnt}); 
        }
    }
    if (temp!=1){
        ret.push_back({temp,1});
    }
    if (ll(ret.size())==0){
        ret.push_back({N,1});
    }
    return ret;
}

set<ll> factorizationset(ll N){
    set<ll> ret;
    if (N==1){
        return ret;
    }
    ll temp = N;
    FOR(i,2,ceil(pow(N,0.5)+1)){
        if (temp%i==0){
            ll cnt = 0;
            while(temp%i==0){
                cnt += 1;
                temp /= i;
            }
            ret.insert(i); 
        }
    }
    if (temp!=1){
        ret.insert(temp);
    }
    return ret;
}

ll  divisorsnum(ll N){//約数の個数
    if (N==1){
        return 1;
    }
    vector<vector<ll>> p = factorization(N);
    ll ret = 1;
    for (const auto & v:p){
        ret *= v[1]+1;
    }
    return ret;
}

vector<ll> make_divisors(ll N){
    vector<ll> lower_divisors , upper_divisors;
    ll i = 1;
    while (i*i <= N){
        if (N%i==0){
            lower_divisors.push_back(i);
            if (i != (N/i)){
                upper_divisors.push_back(N/i);
            }
        }
        i++;
    }
    for (ll i=ll(upper_divisors.size())-1 ; i >= 0; i--){
        lower_divisors.push_back(upper_divisors[i]);
    }
    return lower_divisors;
}

ll invmod(ll a,ll mod){
    if (a==0){
        return 0;
    }
    if (a==1){
        return 1;
    }
    return (mod*mod - invmod(mod % a,mod)*(mod/a))%mod;
}

ll cmbmod(ll n, ll r,ll mod){
    if (n < r) return 0;
    vector<ll> inv = {0,1};
    for (ll i=2 ; i <= min(r,n-r); i++){
        inv.push_back((-inv[mod % i] * (mod / i)) % mod);
    }
    ll cmd = 1;
    for (ll i=1 ; i <= min(r,n-r); i++){
        cmd = (cmd*(n-i+1)+inv[i])%mod;
    }
    return cmd;
}

ll permmod(ll n,ll r,ll mod){
    ll perm = 1;
    for (ll i=n;i>=n-r;i--){
        perm = (perm*i)%mod;
    }
    return perm;
}

ll modPow(ll a,ll n,ll mod){
    if (n==0) return 1;
    if (n==1) return a%mod;
    if (n%2==1){
        return (a*modPow(a,n-1,mod)) % mod;
    }
    ll t = modPow(a,n/2,mod);
    return (t*t)%mod;
}

vector<ll> invmodls(ll n,ll mod){
    vector<ll> inv = {0,1};
    for (ll i=2 ; i <= n;i++){
        inv.push_back((-inv[mod % i] * (mod / i)) % mod);
    }
    return inv;
}

struct NCK{
    ll mod;
    ll N;
    vector<ll> factmod, inv, invfact;
    NCK(ll N,ll mod){
        factmod = {1,1};
        for (ll i=2;i<=N;i++){
            factmod.push_back((factmod[-1]*i)%mod);
        }
        inv = {0,1};
        for (ll i=2;i<=N;i++){
            inv.push_back((-inv[mod % i] * (mod / i)) % mod);
        }
        invfact = {1,1};
        for (ll i=2;i<=N;i++){
            invfact.push_back((invfact[-1]*inv[i])%mod);
        }
    }
    ll nCk(ll a,ll b){
        if (a < b) return 0;
        return ((factmod[a]*invfact[b]%mod)*invfact[a-b])%mod;
    }
    ll invnCk(ll a,ll b){
        return ((factmod[a-b]*invfact[a]%mod)*factmod[b])%mod;
    }
};

vector<vector<vector<ll>>> factorization_all_n(ll n){//以下の自然数すべてをを素因数分解
    vector<vector<vector<ll>>> lspn(n+1);
    vector<ll> lsnum(n+1);
    rep(i,n+1) lsnum[i] = i;
    vector<ll> lsp = set_to_vec(primeset(n));
    sort(lsp.begin(),lsp.end());
    for (const auto & p:lsp){
        for (ll j=1;j<n/p+1;j++){
            ll cnt = 0;
            while (lsnum[p*j]%p==0){
                lsnum[p*j] /= p;
                cnt += 1;
            }
            lspn[j*p].push_back({p,cnt});
        }
    }
    return lspn;
}

ll cnt_string_char(string &st,ll l,ll r,char c){
    ll ret=0;
    for (ll i=l;i<r;i++){
        if (st[i]==c){
            ret += 1;
        }
    }
    return ret;
}

/*
vector<ll> cmbmodls(ll n,ll mod){//二項係数逆元使えないver
    vector<ll> lsans={1};
    vector<ll> lsp = set_to_vec(primeset(n));
    sort(lsp.begin(),lsp.end());
    vector<ll> invp(n+1,0);
    vector<ll> lspmod;
    vector<ll> lsX(ll(lsp.size()),0);
    rep(i,ll(lsp.size())){
        invp[lsp[i]] = i;
        lspmod.push_back(lsp[i]%mod);
    }
}*/




int main(){
    ll D;
    cin >> D;
    string S="xxxxxxxxxxxxxxxx";
    rep(i,14){
        char c;
        cin >> c;
        S += c;
    }
    S += "xxxxxxxxxxxxxxxx";
    ll N = S.size();
    vector<ll> lsf(N);
    vector<ll> lsb(N);
    ll cnt = 0;
    rep(i,N){
        lsf[i] = cnt;
        if (S[i]=='o'){
            cnt += 1;
        }
        else{
            cnt = 0;
        }
    }
    cnt = 0;
    for (ll i = N-1;i>=0;i--){
        if (S[i]=='o'){
            cnt += 1;
        }
        else{
            cnt = 0;
        }
        lsb[i] = cnt;      
    }
    ll ans = 0;
    rep(j,D+1){
        rep(i,N-j){
            if (cnt_string_char(S,i,i+j,'o')==0){
                ans = max(lsf[i]+lsb[i+j]+j,ans);
            }
        }
    }

    cout << ans <<endl;
}
0