Submission #1232638

#TimeUsernameProblemLanguageResultExecution timeMemory
1232638Bui_Quoc_CuongBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
292 ms176828 KiB
# include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = a; i <= (int)b; i++) #define FORD(i, a, b) for (int i = a; i >= (int)b; i--) const int MAXN = 3005; int n, m; int a[MAXN][MAXN]; int cntRow[MAXN][MAXN][2], cntCol[MAXN][MAXN][2]; signed main(){ cin.tie(nullptr) -> sync_with_stdio(false); #define taskname "kieuoanh" if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin >> n >> m; FOR(i, 1, n) FOR(j, 1, m){ char x; cin >> x; if(x == 'J') a[i][j] = 2; if(x == 'O') a[i][j] = 0; if(x == 'I') a[i][j] = 1; } FOR(t, 0, 1){ FOR(i, 1, n){ FOR(j, 1, m){ cntRow[i][j][t] = cntRow[i][j - 1][t] + (a[i][j] == t); cntCol[i][j][t] = cntCol[i - 1][j][t] + (a[i][j] == t); } } } long long ans = 0; FOR(i, 1, n) FOR(j, 1, m){ if(a[i][j] == 2){ int cnt2 = cntRow[i][m][0] - cntRow[i][j - 1][0]; int cnt3 = cntCol[n][j][1] - cntCol[i - 1][j][1]; ans+= 1LL * cnt2 * cnt3; } } cout << ans; return 0; }

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...