Submission #881329

#TimeUsernameProblemLanguageResultExecution timeMemory
881329tsumondaiBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
171 ms159340 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) #define __TIME (1.0 * clock() / CLOCKS_PER_SEC) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 3e3 + 5; const int oo = 1e9, mod = 1e9 + 7; int n, m, preO[N][N], preI[N][N], res=0; char s[N][N]; void process() { cin >> n >> m; foru(i, 1, n) { foru(j, 1, m) { cin >> s[i][j]; } } foru(i, 1, n) { ford(j, m, 1) { preO[i][j] = preO[i][j + 1] + (s[i][j] == 'O'); } } ford(i, n, 1) { foru(j, 1, m) { preI[i][j] = preI[i + 1][j] + (s[i][j] == 'I'); } } foru(i,1,n-1) { foru(j,1,m-1) { if (s[i][j]=='J') res+=(preO[i][j] * preI[i][j]); } } cout << res; return; } signed main() { cin.tie(0)->sync_with_stdio(false); //freopen(".inp", "r", stdin); //freopen(".out", "w", stdout); process(); cerr << "Time elapsed: " << __TIME << " s.\n"; return 0; } /* Xét các trường hợp đặc biệt Kiểm tra lại input/output Cố gắng trâu Lật ngược bài toán Keep calm and get VOI Flow: */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...