Submission #1649836
Source Code Expand
// 基本テンプレート #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <fstream> #include <functional> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define int long long int template<typename T> void chmax(T &a, T b) {a = max(a, b);} template<typename T> void chmin(T &a, T b) {a = min(a, b);} template<typename T> void chadd(T &a, T b) {a = a + b;} typedef pair<int, int> pii; typedef long long ll; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; constexpr ll INF = 1001001001001001LL; constexpr ll MOD = 1000000007LL; vector<pii> nums[100010]; struct Elem { int len, ub, val; bool operator<(const Elem b) const { return len < b.len; } }; signed main() { int R, C; cin >> R >> C; int N; cin >> N; rep(i,0,N) { int r, c, a; cin >> r >> c >> a; r--; c--; nums[r].push_back(pii(c, a)); } rep(i,0,R) sort(nums[i].begin(), nums[i].end()); vector<int> a(R, INF); a[0] = 0; vector<Elem> bars; bool ng = false; rep(i,0,R) rep(j,0,(int)nums[i].size() - 1) { int diff_idx = nums[i][j+1].first - nums[i][j].first; int diff_val = nums[i][j+1].second - nums[i][j].second; bars.push_back(Elem{diff_idx, nums[i][j+1].first, diff_val}); } rep(i,0,bars.size()) { int lb = bars[i].ub - bars[i].len; int ub = bars[i].ub; printf("lb = %lld, ub = %lld, val = %lld\n", lb, ub, bars[i].val); if(a[ub] == INF) { if(a[lb] == INF) a[ub] = bars[i].val; else a[ub] = a[lb] + bars[i].val; } else { if(a[lb] == INF && a[ub] != bars[i].val) ng = true; else if(a[ub] != a[lb] + bars[i].val) ng = true; } } int mi = INF, idx = 0; rep(i,0,R) { if(mi > a[i]) { mi = a[i]; idx = i; } } rep(i,0,R) rep(j,0,(int)nums[i].size()) { int p = nums[i][j].first; int diff_val = a[p] - a[idx]; // printf("mi = %lld, idx = %lld, p = %lld, val = %lld\n", mi, idx, p, diff_val); if(nums[i][j].second + diff_val < 0) ng = true; } cout << (ng ? "No" : "Yes") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Grid and Integers |
User | tsutaj |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2776 Byte |
Status | RE |
Exec Time | 204 ms |
Memory | 9716 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 3 ms | 2560 KB |
0_01.txt | WA | 3 ms | 2560 KB |
0_02.txt | WA | 3 ms | 2560 KB |
0_03.txt | WA | 3 ms | 2560 KB |
0_04.txt | WA | 3 ms | 2560 KB |
1_00.txt | AC | 4 ms | 3328 KB |
1_01.txt | AC | 4 ms | 3328 KB |
1_02.txt | WA | 4 ms | 3328 KB |
1_03.txt | WA | 4 ms | 3328 KB |
1_04.txt | WA | 4 ms | 3328 KB |
1_05.txt | WA | 4 ms | 3328 KB |
1_06.txt | AC | 83 ms | 6528 KB |
1_07.txt | AC | 109 ms | 6528 KB |
1_08.txt | WA | 96 ms | 8052 KB |
1_09.txt | WA | 94 ms | 8052 KB |
1_10.txt | WA | 126 ms | 8820 KB |
1_11.txt | WA | 125 ms | 8824 KB |
1_12.txt | WA | 125 ms | 8824 KB |
1_13.txt | WA | 125 ms | 8824 KB |
1_14.txt | WA | 125 ms | 8820 KB |
1_15.txt | WA | 125 ms | 8820 KB |
1_16.txt | WA | 99 ms | 8824 KB |
1_17.txt | WA | 112 ms | 9336 KB |
1_18.txt | WA | 112 ms | 9332 KB |
1_19.txt | WA | 114 ms | 9332 KB |
1_20.txt | RE | 167 ms | 6136 KB |
1_21.txt | RE | 130 ms | 4032 KB |
1_22.txt | WA | 7 ms | 3200 KB |
1_23.txt | RE | 165 ms | 5628 KB |
1_24.txt | RE | 184 ms | 6520 KB |
1_25.txt | RE | 165 ms | 6136 KB |
1_26.txt | WA | 9 ms | 2944 KB |
1_27.txt | RE | 113 ms | 3200 KB |
1_28.txt | WA | 118 ms | 8564 KB |
1_29.txt | WA | 38 ms | 4544 KB |
1_30.txt | RE | 200 ms | 7032 KB |
1_31.txt | RE | 141 ms | 4544 KB |
1_32.txt | WA | 105 ms | 9328 KB |
1_33.txt | RE | 198 ms | 7032 KB |
1_34.txt | RE | 115 ms | 3200 KB |
1_35.txt | WA | 116 ms | 9328 KB |
1_36.txt | WA | 18 ms | 3712 KB |
1_37.txt | WA | 49 ms | 5240 KB |
1_38.txt | RE | 174 ms | 5884 KB |
1_39.txt | WA | 26 ms | 3968 KB |
1_40.txt | WA | 81 ms | 6520 KB |
1_41.txt | WA | 38 ms | 4672 KB |
1_42.txt | RE | 189 ms | 9716 KB |
1_43.txt | WA | 75 ms | 6264 KB |
1_44.txt | WA | 97 ms | 7416 KB |
1_45.txt | RE | 127 ms | 4096 KB |
1_46.txt | RE | 196 ms | 7032 KB |
1_47.txt | RE | 133 ms | 4348 KB |
1_48.txt | WA | 35 ms | 4348 KB |
1_49.txt | RE | 118 ms | 3200 KB |
1_50.txt | WA | 62 ms | 5624 KB |
1_51.txt | WA | 114 ms | 8820 KB |
1_52.txt | RE | 110 ms | 3200 KB |
1_53.txt | RE | 117 ms | 3456 KB |
1_54.txt | WA | 34 ms | 4416 KB |
1_55.txt | WA | 48 ms | 4988 KB |
1_56.txt | WA | 77 ms | 6392 KB |
1_57.txt | RE | 204 ms | 9332 KB |
1_58.txt | WA | 96 ms | 7416 KB |
1_59.txt | RE | 108 ms | 3072 KB |
1_60.txt | WA | 3 ms | 2560 KB |
1_61.txt | WA | 3 ms | 2560 KB |
1_62.txt | WA | 3 ms | 2560 KB |
1_63.txt | WA | 3 ms | 2560 KB |