AtCoder Beginner Contest 061

Submission #1591700

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<n;i++)
using pii = pair<ll,ll>;
ll INF=LLONG_MAX/10;
ll INIT=-10000000000;
signed main(){
    ll n,m; cin>>n>>m;
    vector<vector<pii>>edge(n,vector<pii>());
    rep(i,m){
        ll a,b,c; cin>>a>>b>>c;
        edge[--a].push_back(pii(--b,c));
    }
    vector<ll>d(n,0);
    vector<bool>visit(n,false);
    visit[0]=true;
    while (true) {
        bool update=false;
        rep(v,n)rep(i,edge[v].size()){
            if(visit[v]==false)continue;
            ll next=edge[v][i].first;
            if(visit[next]==false or (d[next]<d[v]+edge[v][i].second)){
                d[next]=d[v]+edge[v][i].second;
                if(visit[next]==false)visit[next]=true;
                update=true;
                rep(i,edge[next].size()){
                    if(edge[next][i].second+d[next]>d[edge[next][i].first]
                       and visit[edge[next][i].first])return puts("inf")*0;
                }
            }
        }
        if(!update)break;
    }
    cout<<d[--n]<<endl;
}

Submission

Task問題 D - Score Attack
User nameユーザ名 yebityon
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1120 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 0 / 400 sample_01.txt,sample_02.txt,sample_03.txt,subtask_1_1.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt,subtask_1_19.txt,subtask_1_2.txt,subtask_1_20.txt,subtask_1_21.txt,subtask_1_22.txt,subtask_1_23.txt,subtask_1_24.txt,subtask_1_25.txt,subtask_1_26.txt,subtask_1_27.txt,subtask_1_3.txt,subtask_1_4.txt,subtask_1_5.txt,subtask_1_6.txt,subtask_1_7.txt,subtask_1_8.txt,subtask_1_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_1.txt AC 1 ms 256 KB
subtask_1_10.txt AC 1 ms 256 KB
subtask_1_11.txt AC 2 ms 256 KB
subtask_1_12.txt AC 2 ms 256 KB
subtask_1_13.txt AC 1 ms 256 KB
subtask_1_14.txt AC 2 ms 256 KB
subtask_1_15.txt AC 3 ms 384 KB
subtask_1_16.txt AC 1 ms 256 KB
subtask_1_17.txt AC 1 ms 256 KB
subtask_1_18.txt AC 2 ms 256 KB
subtask_1_19.txt AC 2 ms 384 KB
subtask_1_2.txt AC 2 ms 256 KB
subtask_1_20.txt AC 1 ms 256 KB
subtask_1_21.txt AC 2 ms 256 KB
subtask_1_22.txt AC 3 ms 384 KB
subtask_1_23.txt WA
subtask_1_24.txt WA
subtask_1_25.txt WA
subtask_1_26.txt AC 5 ms 256 KB
subtask_1_27.txt WA
subtask_1_3.txt AC 2 ms 256 KB
subtask_1_4.txt AC 2 ms 256 KB
subtask_1_5.txt AC 1 ms 256 KB
subtask_1_6.txt AC 2 ms 256 KB
subtask_1_7.txt AC 2 ms 256 KB
subtask_1_8.txt AC 2 ms 256 KB
subtask_1_9.txt AC 1 ms 256 KB