Submission #753075

#TimeUsernameProblemLanguageResultExecution timeMemory
753075CdSBitaro the Brave (JOI19_ho_t1)C++17
20 / 100
9 ms3668 KiB
#include <bits/stdc++.h>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int h, w;

    cin >> h >> w;

    vector<pair<int, int>> joia;
    int orbes[h+1][w+1];
    int ingots[h+1][w+1];
    orbes[0][0] = 0;
    ingots[0][0] = 0;

    for (int i = 1; i <= h; i++)
    {
	for (int j = 1; j <= w; j++)
	{
	    char x;
	    cin >> x;
	    if (x == 'J') 
	    {
		joia.push_back({i, j});
	    }
	    orbes[i][j] = orbes[i][j-1];
	    if (x == 'O') 
	    {
		orbes[i][j] += 1;
	    }
	    ingots[i][j] = ingots[i-1][j];
	    if (x == 'I')
	    {
		ingots[i][j] += 1;
	    }
	}
    }

    int ans = 0;

    for (auto i : joia)
    {
	int a = orbes[i.first][w] - orbes[i.first][i.second];
	int b = ingots[h][i.second] - ingots[i.first][i.second];

	ans+=a*b;
    }

    cout << ans;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...