Submission #467570

#TimeUsernameProblemLanguageResultExecution timeMemory
467570MN22Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
383 ms88404 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define endl "\n" #define yn ynnnnnn using namespace std; const int INF = 1000000007; const int N = 3005; int dpi[N][N], dpo[N][N]; char a[N][N]; int h, w; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> h >> w; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { cin >> a[i][j]; } } for(int j = 1; j <= w; j++) { for(int i = 1; i <= h; i++) { if(a[i][j] == 'I') { dpi[i][j] = dpi[i-1][j] + 1; } else { dpi[i][j] = dpi[i-1][j]; } } } for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { if(a[i][j] == 'O') { dpo[i][j] = dpo[i][j-1] + 1; } else { dpo[i][j] = dpo[i][j-1]; } } } int ansi, anso; ll res = 0; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { if(a[i][j] == 'J') { ansi = dpi[h][j] - dpi[i-1][j]; anso = dpo[i][w] - dpo[i][j-1]; //cout << ansi << " " << anso << endl; res += 1ll * ansi * anso; } } } cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...