제출 #859086

#제출 시각아이디문제언어결과실행 시간메모리
85908675_yabuki여행하는 상인 (APIO17_merchant)C++14
컴파일 에러
0 ms0 KiB
#define _DEBU132213G
// #include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
// using namespace atcoder;
#define endl "\n"
#define fi first
#define se second
#define all(x) (x).begin(),(x).end() 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<pii> vii;
const long double pi = acos(-1.0);
const int INF = 1987654321;
const ll LLINF = 2e18;
const double eps = 1e-9;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T>
auto Vector(const int n, const T& val) { return vector(n, val); }
template<typename... Ts>
auto Vector(const int n, Ts... args) { return vector(n, Vector(args...)); }
//

ll buy[104][2004];
ll sell[104][2004];
ll dist[104][104];
ll bs[104][104];
ll newdist[104][104];

struct Edge{
    int u, v, weight;
    bool operator<(Edge const& other){
        return weight < other.weight;
    }
};

int main(){
#ifdef _DEBUG   
    freopen ("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif      
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, M, K; cin >> N >> M >> K;
    for(int i = 1; i <= N; i++){
        for(int k = 1; k <= K; k++){
            cin >> buy[i][k] >> sell[i][k];
        }
    }   
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++) dist[i][j] = LLINF;
    }
        
    while(M--){
        ll u, v, w; cin >> u >> v >> w;
        // adj[u].push_back({v, w});
        chmin(dist[u][v], w);
    }

    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            dist[i][i] = 0;
            for(int j = 1; j <= N; j++){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
     // item
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(i==j) continue;
            for(int k = 1; k <= K; k++){
                if(sell[j][k] != -1 && buy[i][k] != -1){
                    chmax(bs[i][j], 1LL* sell[j][k]-buy[i][k]);   
                }
            }
        }
    }

    // for(int i = 1; i <= N; i++){
    //     for(int j = 1; j <= N; j++){
    //         if(dist[i][j] == LLINF) newdist[i][j] = LLINF-bs[i][j];
    //         else newdist[i][j] = dist[i][j] - bs[i][j];
    //     }
    // }
    // for(int i = 1; i <= N; i++){
    //     for(int j= 1; j <= N; j++){
    //         newdist[i][j] = LLINF;
    //     }
    // }   
    // for(int k = 1; k <= N; k++){
    //     for(int i = 1; i <= N; i++){
    //         for(int j = 1; j <= N; j++){
    //             chmin(newdist[i][j], newdist[i][k] + newdist[k][j]);
    //         }
    //     }
    // }
    // bool flag = false;
    // for(int i = 1; i <= N; i++){
    //     if(newdist[i][i] < 0) flag = true; break;
    // }
    // if(flag){
    //     cout << 0 << endl;
    //     return 0;
    // }
    
    ll lo = 0, hi = 2e9;
    while(lo + 1 < hi){
        ll mid = (lo + hi) / 2;
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                newdist[i][j] = LLINF;
            }
        }
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                if(i==j) continue;
                if(dist[i][j] == LLINF) continue;
                chmin(newdist[i][j], 1LL*mid*dist[i][j] - bs[i][j]);
            }
        }
        
        for(int k = 1; k <= N; k++){
            for(int i = 1; i <= N; i++){
                for(int j = 1; j <= N; j++){
                    chmin(newdist[i][j], newdist[i][k] + newdist[k][j]);
                }
            }
        }
        bool flag = false;
        for(int i = 1; i <= N; i++){
            if(newdist[i][i] <= 0) flag = true; break;
        }
        if(flag) lo = mid;
        else hi = mid;
    }    
    cout << lo << endl;
    
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

merchant.cpp: In function 'auto Vector(int, const T&)':
merchant.cpp:24:55: error: missing template arguments before '(' token
   24 | auto Vector(const int n, const T& val) { return vector(n, val); }
      |                                                       ^
merchant.cpp: In function 'auto Vector(int, Ts ...)':
merchant.cpp:26:53: error: missing template arguments before '(' token
   26 | auto Vector(const int n, Ts... args) { return vector(n, Vector(args...)); }
      |                                                     ^
merchant.cpp: In function 'int main()':
merchant.cpp:138:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  138 |             if(newdist[i][i] <= 0) flag = true; break;
      |             ^~
merchant.cpp:138:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  138 |             if(newdist[i][i] <= 0) flag = true; break;
      |                                                 ^~~~~