Submission #716227

#TimeUsernameProblemLanguageResultExecution timeMemory
716227hpesojBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
324 ms150252 KiB
#include <bits/stdc++.h> #define int long long #define pi pair <int, int> #define ppi pair <pi, int> #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << '\n' #define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n' #define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n' using namespace std; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const int inf = 1000000000; int h, w, ans; char grid[3005][3005]; int suffrow[3005][3005], suffcol[3005][3005]; //row count orb, column count ingot signed main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> h >> w; for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) cin >> grid[i][j]; for(int i = 1; i <= h; i++) for(int j = w; j >= 1; j--){ suffrow[i][j] = suffrow[i][j+1]; if(grid[i][j] == 'O') suffrow[i][j]++; } for(int j = 1; j <= w; j++) for(int i = h; i >= 1; i--){ suffcol[j][i] = suffcol[j][i+1]; if(grid[i][j] == 'I') suffcol[j][i]++; } for(int i = 1; i < h; i++) for(int j = 1; j < w; j++){ if(grid[i][j] != 'J') continue; ans += suffrow[i][j+1] * suffcol[j][i+1]; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...