Submission #1725856
Source Code Expand
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef vector<VL> VVL; typedef pair<int,int> P; typedef pair<ll,ll> PL; const ll INF = 1e18; const int N = 1e5; ll a[N], b[N]; VI ea[N], eb[N], sa[N], sb[N]; void dfsb(int); void dfsa(int now){ REP(i,ea[now].size()){ int next = ea[now][i]; ll sum = sa[now][i]; if (b[next] < INF) continue; b[next] = sum - a[now]; dfsb(next); } } void dfsb(int now){ REP(i,eb[now].size()){ int next = eb[now][i]; ll sum = sb[now][i]; if (a[next] < INF) continue; a[next] = sum - b[now]; dfsa(next); } } int main(){ int r, c, n; cin >> r >> c >> n; fill(a, a+r, INF); fill(b, b+c, INF); VI x(n), y(n), s(n); REP(i,n){ int rr, cc, ss; scanf("%d %d %d", &rr, &cc, &ss); rr--; cc--; x[i] = rr; y[i] = cc; s[i] = ss; ea[rr].push_back(cc); sa[rr].push_back(ss); eb[cc].push_back(rr); sb[cc].push_back(ss); } REP(i,n){ if (a[x[i]] < INF) continue; a[x[i]] = 0; dfsa(x[i]); } ll mia = INF, mib = INF; REP(i,r) mia = min(mia, a[i]); REP(i,c) mib = min(mib, b[i]); if (mia + mib < 0){ cout << "No" << endl; return 0; } REP(i,n){ if (a[x[i]] + b[y[i]] != s[i]){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Grid and Integers |
User | TangentDay |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2053 Byte |
Status | WA |
Exec Time | 131 ms |
Memory | 24832 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:66:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d %d", &rr, &cc, &ss); ^
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 | AC | 6 ms | 10496 KB |
0_01.txt | AC | 6 ms | 10496 KB |
0_02.txt | AC | 6 ms | 10496 KB |
0_03.txt | AC | 6 ms | 10496 KB |
0_04.txt | AC | 6 ms | 10496 KB |
1_00.txt | AC | 7 ms | 11136 KB |
1_01.txt | AC | 6 ms | 11136 KB |
1_02.txt | AC | 6 ms | 11136 KB |
1_03.txt | AC | 6 ms | 11136 KB |
1_04.txt | AC | 6 ms | 11136 KB |
1_05.txt | AC | 7 ms | 11136 KB |
1_06.txt | AC | 117 ms | 24832 KB |
1_07.txt | AC | 131 ms | 24832 KB |
1_08.txt | AC | 104 ms | 20736 KB |
1_09.txt | AC | 73 ms | 20736 KB |
1_10.txt | AC | 87 ms | 18560 KB |
1_11.txt | AC | 101 ms | 18560 KB |
1_12.txt | AC | 110 ms | 24832 KB |
1_13.txt | AC | 106 ms | 24832 KB |
1_14.txt | AC | 102 ms | 24832 KB |
1_15.txt | AC | 96 ms | 24832 KB |
1_16.txt | AC | 99 ms | 23552 KB |
1_17.txt | AC | 100 ms | 24448 KB |
1_18.txt | AC | 98 ms | 23552 KB |
1_19.txt | AC | 99 ms | 23040 KB |
1_20.txt | AC | 44 ms | 15616 KB |
1_21.txt | WA | 25 ms | 13696 KB |
1_22.txt | WA | 8 ms | 11264 KB |
1_23.txt | WA | 50 ms | 16896 KB |
1_24.txt | AC | 53 ms | 16768 KB |
1_25.txt | AC | 44 ms | 16000 KB |
1_26.txt | WA | 9 ms | 11136 KB |
1_27.txt | WA | 12 ms | 11776 KB |
1_28.txt | AC | 76 ms | 19456 KB |
1_29.txt | WA | 26 ms | 14208 KB |
1_30.txt | AC | 74 ms | 18816 KB |
1_31.txt | WA | 37 ms | 15104 KB |
1_32.txt | AC | 50 ms | 16000 KB |
1_33.txt | AC | 70 ms | 18816 KB |
1_34.txt | WA | 13 ms | 11904 KB |
1_35.txt | AC | 47 ms | 14976 KB |
1_36.txt | WA | 15 ms | 12544 KB |
1_37.txt | AC | 29 ms | 13824 KB |
1_38.txt | WA | 56 ms | 17536 KB |
1_39.txt | WA | 20 ms | 13440 KB |
1_40.txt | WA | 49 ms | 17408 KB |
1_41.txt | WA | 28 ms | 14848 KB |
1_42.txt | AC | 55 ms | 16768 KB |
1_43.txt | AC | 48 ms | 17024 KB |
1_44.txt | AC | 54 ms | 17536 KB |
1_45.txt | AC | 19 ms | 12544 KB |
1_46.txt | AC | 64 ms | 18688 KB |
1_47.txt | AC | 23 ms | 13184 KB |
1_48.txt | AC | 23 ms | 13184 KB |
1_49.txt | WA | 11 ms | 11776 KB |
1_50.txt | AC | 38 ms | 15488 KB |
1_51.txt | AC | 64 ms | 18176 KB |
1_52.txt | WA | 10 ms | 11648 KB |
1_53.txt | WA | 131 ms | 12544 KB |
1_54.txt | WA | 24 ms | 13824 KB |
1_55.txt | AC | 26 ms | 13568 KB |
1_56.txt | AC | 49 ms | 16640 KB |
1_57.txt | AC | 79 ms | 18432 KB |
1_58.txt | AC | 61 ms | 18048 KB |
1_59.txt | WA | 9 ms | 11392 KB |
1_60.txt | AC | 6 ms | 10496 KB |
1_61.txt | AC | 6 ms | 10496 KB |
1_62.txt | AC | 6 ms | 10496 KB |
1_63.txt | AC | 6 ms | 10496 KB |