Submission #2860455
Source Code Expand
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <utility> # include <stack> # include <queue> # include <list> # include <tuple> # include <unordered_map> # include <numeric> # include <complex> # include <bitset> # include <random> # include <chrono> # include <cstdlib> # include <tuple> # include <array> # include <climits> #define ll long long #define rep(i,rept) for (ll i = 0; i < rept; i++) #define yes(b) std::cout<< (b ? "Yes" : "No") #define YES(b) std::cout<< (b ? "YES" : "NO") const ll INF = 1LL << 50; using namespace std; int main(void) { int n, m, a[2000], b[1000]; ll ans, c[2000], dist[1000]; bool negative[1000]; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a[i] >> b[i] >> c[i]; c[i] = -c[i]; } dist[0] = 0; for (int i = 1; i < n; ++i) { dist[i] = INF; } for (int i = 0; i < n - 1; ++i) { for (int j = 0; j < m; ++j) { if (dist[a[j] - 1] == INF) { continue; } if (dist[b[j] - 1] >(dist[a[j] - 1] + c[j])) { dist[b[j] - 1] = (dist[a[j] - 1] + c[j]); } } } ans = dist[n - 1]; for (int i = 0; i < n; ++i) { negative[i] = false; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (dist[a[j] - 1] == INF) { continue; } if (dist[b[j] - 1] > dist[a[j] - 1] + c[j]) { dist[b[j] - 1] = (dist[a[j] - 1] + c[j]); negative[b[j] - 1] = true; } if (negative[a[j] - 1] == true) { negative[b[j] - 1] = true; } } } if (negative[n - 1]) { cout << "inf" << endl; } else { cout << -ans << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Score Attack |
User | leaf2326 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1775 Byte |
Status | WA |
Exec Time | 13 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
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 | 2 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 | 7 ms | 256 KB |
subtask_1_13.txt | AC | 1 ms | 256 KB |
subtask_1_14.txt | AC | 7 ms | 256 KB |
subtask_1_15.txt | AC | 12 ms | 256 KB |
subtask_1_16.txt | AC | 1 ms | 256 KB |
subtask_1_17.txt | AC | 1 ms | 256 KB |
subtask_1_18.txt | WA | 6 ms | 256 KB |
subtask_1_19.txt | WA | 5 ms | 256 KB |
subtask_1_2.txt | AC | 5 ms | 256 KB |
subtask_1_20.txt | AC | 1 ms | 256 KB |
subtask_1_21.txt | AC | 5 ms | 256 KB |
subtask_1_22.txt | WA | 13 ms | 256 KB |
subtask_1_23.txt | AC | 1 ms | 256 KB |
subtask_1_24.txt | WA | 7 ms | 256 KB |
subtask_1_25.txt | AC | 4 ms | 256 KB |
subtask_1_26.txt | AC | 5 ms | 256 KB |
subtask_1_27.txt | AC | 7 ms | 256 KB |
subtask_1_3.txt | AC | 4 ms | 256 KB |
subtask_1_4.txt | AC | 5 ms | 256 KB |
subtask_1_5.txt | AC | 3 ms | 256 KB |
subtask_1_6.txt | AC | 7 ms | 256 KB |
subtask_1_7.txt | AC | 5 ms | 256 KB |
subtask_1_8.txt | AC | 5 ms | 256 KB |
subtask_1_9.txt | AC | 1 ms | 256 KB |