Submission #849131

#TimeUsernameProblemLanguageResultExecution timeMemory
849131luanmengleiRobogolf (ROI19_golf)C++17
20 / 100
31 ms15192 KiB
#include <bits/stdc++.h> using namespace std; void debug(const char *msg, ...) { #ifdef CLESIP va_list arg; static char pbString[512]; va_start(arg, msg); vsprintf(pbString, msg, arg); cerr << "[DEBUG] " << pbString << "\n"; va_end(arg); #endif } using i64 = long long; const int N = 1010; const i64 P = 998244353; bool v[N][N]; int a[N][N], n, m, k, f[N][N][2]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m >> k; for (int i = 1, x, y; i <= k; i ++) { cin >> x >> y; cin >> a[x][y]; v[x][y] = true; } for (int i = n; i >= 1; i --) { for (int j = m; j >= 1; j --) { if (v[i][j]) { f[i][j][0] = f[i][j][1] = a[i][j]; } else { f[i][j][0] = min(f[i + 1][j][1], f[i][j + 1][1]); f[i][j][1] = max(f[i + 1][j][0], f[i][j + 1][0]); } } } i64 ans = 0; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { ans = (ans + f[i][j][0] % P + P) % P; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...