Submission #252876

#TimeUsernameProblemLanguageResultExecution timeMemory
252876BadrangiikhTravelling Merchant (APIO17_merchant)C++14
0 / 100
32 ms384 KiB
#include<bits/stdc++.h>
#include <deque> 
#include <cmath>
using namespace std;
 
#define ll long long 
 
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
 
long long n , m , k , i , maxx , minn , x , y , j , z , sz ;
long long used [ 145 ] ;
vector < long long > vec [ 145 ] ;
map < pair < long long , long long > , long long > mp ;

void go ( long long par , long long len ) {
    used [ par ] = 1 ;
    sz = vec [ par ] . size ( ) ;
    for ( long long i = 0 ; i < sz ; i ++ ) {
        if ( vec [ par ] [ i ] == 1 ) {
            minn = min ( minn , len + mp [ { par , vec [ par ] [ i ] } ] ) ;
            return ;
        }
        if ( vec [ par ] [ i ] == par ) continue ;
        if ( used [ vec [ par ] [ i ] ] == 1 ) continue ;
        used [ vec [ par ] [ i ] ] = 1 ;
        go ( vec [ par ] [ i ] , len + mp [ { par , vec [ par ] [ i ] } ] ) ;
    }
}

int main() {
    scanf ( "%lld%lld%lld" , & n , & m , & k ) ;
    maxx = 0 ;
    for ( i = 1 ; i <= n ; i ++ ) {
        for ( j = 1 ; j <= k ; j ++ ) {
            scanf ( "%lld%lld" , & x , & y ) ;
            if ( i == 1 && x > 0 && y > 0 ) {
                maxx = max ( maxx , y - x ) ;
            }
        }
    }
    for ( i = 1 ; i <= m ; i ++ ) {
        scanf ( "%lld%lld%lld" , & x , & y , & z ) ;
        vec [ x ] . push_back ( y ) ;
        mp [ { x , y } ] = z ;
    }
    if ( vec [ 1 ] . size ( ) == 0 || maxx == 0 ) {
        printf ( "0" ) ;
        exit (0) ;
    }
    minn = 1234567890 ;
    go ( 1 , 0 ) ;
    printf ( "%lld" , maxx / minn ) ;
}    

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:32:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ( "%lld%lld%lld" , & n , & m , & k ) ;
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:36:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf ( "%lld%lld" , & x , & y ) ;
             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:43:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ( "%lld%lld%lld" , & x , & y , & z ) ;
         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...