結果

問題 No.3041 非対称じゃんけん
ユーザー jiyujin816
提出日時 2025-02-28 22:25:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 3,445 bytes
コンパイル時間 3,834 ms
コンパイル使用メモリ 284,116 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2025-02-28 22:25:56
合計ジャッジ時間 8,204 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//以下cout時の色設定
#define COUTRESET "\033[0m" // 色をリセット
#define COUTRED "\033[31m" // 赤色
#define COUTGREEN "\033[32m" // 緑色
#define COUTYELLOW "\033[33m" // 黄色
#define COUTBLUE "\033[34m" // 青色
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<int,int>;
const ll INF=9*1e15; 
const vector<ll> dx={0,0,1,-1};
const vector<ll> dy={1,-1,0,0};
#define rep(i,N) for(int i=0;i<N;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
template <typename T1,typename T2>
ostream& operator<<(ostream &os,pair<T1,T2> &P){
    return os<<"("<<P.first<<","<<P.second<<") ";
}
template<typename T>
ostream& operator<<(ostream &os,vector<T> vec){
    for(auto val:vec){
        os<<val<<" ";
    }
    return os<<"\n";
}
template <typename T> void print(const T &vec){
    int i=0;
    for(auto val:vec){
        cout<<i<<":"<<val<<",";
        i++;
    }
    cout<<'\n';
}
template<typename T> void print2(const vector<vector<T>> &vec){
    int i=0;
    for(auto v:vec){
        cout<<i<<": ";
        for(auto a:v){
            cout<<a<<" ";
        }
        i++;
        cout<<'\n';
    }
}
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
    return;
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
    return;
}
template<typename T> struct DualSegtree{
    int siz;
    int N;
    int log;
    vector<T> data;
    int ceil_pow2(int n) {
        int x = 0;
        while ((1U << x) < (unsigned int)(n)) x++;
        return x;
    }
    DualSegtree(){}
    DualSegtree(int n){
        N=n;
        log=ceil_pow2(n);
        siz=1<<log;
        data.resize(siz*2+1,0);
    }
    DualSegtree(const vector<T> &vec){
        N=(int)vec.size();
        log=ceil_pow2(N);
        siz=1<<log;
        data.resize(siz*2+1);
        for(int i=0;i<N;i++){
            data[i+siz]=vec[i];
        }
    }
    void add(int p,T x){
        assert(0<=p && p<N);
        data[p+siz]+=x;
    }
    void add(int l,int r,T x){
        assert(0<=l && l<=r && r<=N);
        l+=siz;
        r+=siz;
        while(l<r){
            if(l&1){
                data[l]+=x;
                l++;
            }
            if(r&1){
                data[r-1]+=x;
                r--;
            }
            l>>=1;
            r>>=1;
        }
        return;
    }
    T get(int p){
        assert(0<=p && p<N);
        T ret=data[p+siz];
        int idx=p+siz;
        while(idx!=1){
            idx/=2;
            ret+=data[idx];
        }
        return ret;
    }
    void set(int p,T x){
        assert(0<=p && p<N);
        add(p,x-get(p));
        return;
    }
};
int main(){
    cin.tie(0)->sync_with_stdio(0);
    ll N,F;
    cin>>N>>F;
    vector<vector<int>> hand(N,vector<int>(3));
    rep(i,3){
        rep(j,N){
            cin>>hand[j][i];
        }
    }
    queue<pair<int,int>> que;
    que.push({0,0});
    vector<int> ans(N+1);
    ans[0]=0;
    int now=0;
    vector<int> seen(F*N+10,-1);
    while(!que.empty()){
        P v=que.front();
        que.pop();
        now=v.second;
        if(seen[v.first]==now){
            continue;
        }
        seen[v.first]=now;
        ans[now]++;
        if(now==N){
        	continue;
        }
        for(int i=0;i<3;i++){
            que.push({v.first+hand[now][i],now+1});
        }
    }
    for(int i=1;i<=N;i++){
        cout<<ans[i]<<'\n';
    }
}
0