Submission #6838302


Source Code Expand

Copy
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int sz=5005;
long long d[sz];
int n,m,p;
int f[sz],t[sz],w[sz];
long long inf=1e18,ans;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d %d",&n,&m,&p);
   for(int i=0;i<m;i++){
        scanf("%d %d %d",&f[i],&t[i],&w[i]);
        w[i]=p-w[i];
    }
    for(int i=1;i<=n;i++) d[i]=inf;
    bool flag=0;
    d[1]=0;
    for(int i=0;i<3*n;i++){
        for(int j=0;j<m;j++){
            int u=f[j];
            int v=t[j];
            int k=w[j];
            if(d[u]>=inf) continue;
            if(d[v]>d[u]+k){
                flag=(v==n&&i>=n);
                d[v]=max(d[u]+k,-inf);
            }
        }
        if(flag){
            cout<<-1;
            return 0;
        }
    }
    if(d[n]==inf) cout<<-1;
    else{
        d[n]=-d[n];
        ans=max(ans,d[n]);
        cout<<ans;
    }
    return 0;
}

Submission Info

Submission Time
Task E - Coins Respawn
User winstonwolf
Language C++14 (GCC 5.4.1)
Score 0
Code Size 996 Byte
Status WA
Exec Time 239 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&m,&p);
                               ^
./Main.cpp:17:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&f[i],&t[i],&w[i]);
                                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 42
WA × 14
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 WA 1 ms 256 KB
b06 AC 1 ms 256 KB
b07 AC 1 ms 256 KB
b08 AC 1 ms 256 KB
b09 AC 16 ms 256 KB
b10 AC 30 ms 256 KB
b11 AC 20 ms 256 KB
b12 AC 14 ms 256 KB
b13 WA 25 ms 256 KB
b14 AC 30 ms 256 KB
b15 AC 2 ms 256 KB
b16 WA 2 ms 256 KB
b17 AC 2 ms 256 KB
b18 AC 30 ms 256 KB
b19 AC 30 ms 256 KB
b20 AC 16 ms 256 KB
b21 WA 30 ms 256 KB
b22 AC 14 ms 256 KB
b23 AC 30 ms 256 KB
b24 AC 14 ms 256 KB
b25 AC 1 ms 256 KB
b26 AC 44 ms 384 KB
b27 AC 44 ms 256 KB
b28 AC 44 ms 384 KB
b29 WA 47 ms 384 KB
b30 WA 46 ms 384 KB
b31 WA 45 ms 384 KB
b32 AC 45 ms 384 KB
b33 AC 46 ms 256 KB
b34 AC 46 ms 256 KB
b35 AC 47 ms 256 KB
b36 AC 48 ms 384 KB
b37 AC 48 ms 256 KB
b38 AC 44 ms 256 KB
b39 AC 44 ms 256 KB
b40 AC 44 ms 384 KB
b41 AC 44 ms 384 KB
b42 AC 44 ms 256 KB
b43 WA 226 ms 384 KB
b44 WA 217 ms 384 KB
b45 WA 239 ms 384 KB
b46 WA 214 ms 384 KB
b47 AC 27 ms 384 KB
b48 AC 23 ms 256 KB
b49 AC 30 ms 256 KB
b50 WA 44 ms 256 KB
b51 AC 16 ms 256 KB
b52 WA 44 ms 256 KB
b53 WA 30 ms 256 KB
b54 AC 43 ms 256 KB
b55 AC 51 ms 256 KB
b56 AC 59 ms 256 KB