제출 #1037861

#제출 시각아이디문제언어결과실행 시간메모리
1037861mateuszwesBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
203 ms159312 KiB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define F first
#define S second
#define pb push_back
#define pi pair<int,int>
#define pl pair<ll,ll>
 
using namespace std;
constexpr int debug = 0;
constexpr int N = 3007;

ll ignots[N][N];		//amount of ignots below the given point;
ll orbs[N][N];			//amount of orbs on the right
char tab[N][N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int rows, columns; cin >> rows >> columns;
	ll sc = 0;
	for(int y = 0; y < rows; y++){
		for(int x = 0; x < columns; x++){
			cin >> tab[x][y];
		}
	}
	for(int y = rows-1; y >= 0; y--){
		for(int x = columns-1; x >= 0; x--){
			ignots[x][y] = ignots[x][y+1];
			orbs[x][y] = orbs[x+1][y];
			if(tab[x][y] == 'J') sc += ignots[x][y]*orbs[x][y];
			else if(tab[x][y] == 'O') orbs[x][y]++;
			else ignots[x][y]++;
		}
	}
	cout << sc;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...