Submission #1725867
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]; VL 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 | 2057 Byte |
Status | WA |
Exec Time | 105 ms |
Memory | 24832 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:67: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 | 5 ms | 10496 KB |
0_01.txt | AC | 5 ms | 10496 KB |
0_02.txt | AC | 5 ms | 10496 KB |
0_03.txt | AC | 5 ms | 10496 KB |
0_04.txt | AC | 5 ms | 10496 KB |
1_00.txt | AC | 5 ms | 11136 KB |
1_01.txt | AC | 5 ms | 11136 KB |
1_02.txt | AC | 5 ms | 11136 KB |
1_03.txt | AC | 5 ms | 11136 KB |
1_04.txt | AC | 5 ms | 11136 KB |
1_05.txt | AC | 5 ms | 11136 KB |
1_06.txt | AC | 92 ms | 24832 KB |
1_07.txt | AC | 105 ms | 24832 KB |
1_08.txt | AC | 83 ms | 20736 KB |
1_09.txt | AC | 75 ms | 20736 KB |
1_10.txt | AC | 74 ms | 18560 KB |
1_11.txt | AC | 77 ms | 18560 KB |
1_12.txt | AC | 79 ms | 24832 KB |
1_13.txt | AC | 75 ms | 24832 KB |
1_14.txt | AC | 87 ms | 24832 KB |
1_15.txt | AC | 93 ms | 24832 KB |
1_16.txt | AC | 73 ms | 23552 KB |
1_17.txt | AC | 73 ms | 24448 KB |
1_18.txt | AC | 81 ms | 23552 KB |
1_19.txt | AC | 78 ms | 23040 KB |
1_20.txt | AC | 42 ms | 16128 KB |
1_21.txt | WA | 21 ms | 13696 KB |
1_22.txt | WA | 7 ms | 11392 KB |
1_23.txt | WA | 54 ms | 17024 KB |
1_24.txt | AC | 52 ms | 17408 KB |
1_25.txt | AC | 43 ms | 16256 KB |
1_26.txt | WA | 8 ms | 11136 KB |
1_27.txt | WA | 11 ms | 11776 KB |
1_28.txt | AC | 73 ms | 19968 KB |
1_29.txt | WA | 24 ms | 14208 KB |
1_30.txt | AC | 68 ms | 19200 KB |
1_31.txt | WA | 32 ms | 15104 KB |
1_32.txt | AC | 51 ms | 16768 KB |
1_33.txt | AC | 80 ms | 19200 KB |
1_34.txt | WA | 12 ms | 11904 KB |
1_35.txt | AC | 48 ms | 16000 KB |
1_36.txt | WA | 13 ms | 12544 KB |
1_37.txt | AC | 27 ms | 14080 KB |
1_38.txt | WA | 53 ms | 17664 KB |
1_39.txt | WA | 17 ms | 13440 KB |
1_40.txt | WA | 46 ms | 17536 KB |
1_41.txt | WA | 26 ms | 14976 KB |
1_42.txt | AC | 53 ms | 17536 KB |
1_43.txt | AC | 44 ms | 17152 KB |
1_44.txt | AC | 52 ms | 18048 KB |
1_45.txt | AC | 18 ms | 12672 KB |
1_46.txt | AC | 62 ms | 19072 KB |
1_47.txt | AC | 21 ms | 13312 KB |
1_48.txt | AC | 22 ms | 13184 KB |
1_49.txt | WA | 10 ms | 11776 KB |
1_50.txt | AC | 36 ms | 15744 KB |
1_51.txt | AC | 60 ms | 18944 KB |
1_52.txt | WA | 8 ms | 11648 KB |
1_53.txt | WA | 13 ms | 12416 KB |
1_54.txt | WA | 22 ms | 13824 KB |
1_55.txt | AC | 25 ms | 13952 KB |
1_56.txt | AC | 45 ms | 17024 KB |
1_57.txt | AC | 63 ms | 19328 KB |
1_58.txt | AC | 57 ms | 18432 KB |
1_59.txt | WA | 7 ms | 11392 KB |
1_60.txt | AC | 5 ms | 10496 KB |
1_61.txt | AC | 5 ms | 10496 KB |
1_62.txt | AC | 5 ms | 10496 KB |
1_63.txt | AC | 5 ms | 10496 KB |