Submission #320990

#TimeUsernameProblemLanguageResultExecution timeMemory
320990MN22Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
399 ms88548 KiB
/* ░██████╗░█████╗░░██████╗██╗░░░██╗ ░██████╗░░█████╗░████████╗░█████╗░ ██╔════╝██╔══██╗██╔════╝██║░░░██║ ██╔════╝░██╔══██╗╚══██╔══╝██╔══██╗ ╚█████╗░██║░░██║╚█████╗░██║░░░██║ ██║░░██╗░███████║░░░██║░░░███████║ ░╚═══██╗██║░░██║░╚═══██╗██║░░░██║ ██║░░╚██╗██╔══██║░░░██║░░░██╔══██║ ██████╔╝╚█████╔╝██████╔╝╚██████╔╝ ╚██████╔╝██║░░██║░░░██║░░░██║░░██║ ╚═════╝░░╚════╝░╚═════╝░░╚═════╝░ ░╚═════╝░╚═╝░░╚═╝░░░╚═╝░░░╚═╝░░╚═╝ */ #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> using namespace std; const int INF = 1000000007; const int N = 3005; char a[N][N]; int po[N][N], pi[N][N]; int main() { ios_base :: sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { po[i][j] = po[i][j - 1] + (a[i][j] == 'O'); } } for (int j = 0; j < m; j++) { for (int i = 0; i < n; i++) { pi[i][j] = pi[i - 1][j] + (a[i][j] == 'I'); } } int co, ci; long long res = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j] == 'J') { co = po[i][m - 1] - po[i][j - 1]; ci = pi[n - 1][j] - pi[i - 1][j]; res += 1LL * co * ci; } } } cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...