Submission #230215

# Submission time Handle Problem Language Result Execution time Memory
230215 2020-05-09T07:11:45 Z AMO5 Bitaro the Brave (JOI19_ho_t1) C++
100 / 100
194 ms 120256 KB
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=3e3+3;

string s[mxn];
int orb[mxn][mxn],ing[mxn][mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int h,w;
	cin >> h >> w;
	for(int i=0; i<h; i++){
		cin >> s[i];
	}
	for(int i=0; i<=h; i++){
		for(int j=0; j<=w; j++){
			orb[i][j]=0;
			ing[i][j]=0;
		}
	}
	vector<ii>J;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]=='J')J.pb(ii(i,j));
			else if(s[i][j]=='O')orb[i][j]=1;
			else ing[i][j]=1;
		}
	}
	for(int i=h-1; i>=0; i--){
		for(int j=w-1; j>=0; j--){
			orb[i][j] += orb[i][j+1];
			ing[i][j] += ing[i+1][j];
		}
	}
	ll ans=0;
	for(ii j:J){
		int x = j.fi;
		int y = j.se;
		//cerr << x <<  ' ' << y << ' ' << orb[x][y] << ' ' << ing[x][y] << endl;
		ans += ll(orb[x][y])*ing[x][y];
	}
	cout << ans << endl;
}	
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 1408 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 5 ms 1280 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1408 KB Output is correct
13 Correct 5 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 1408 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 5 ms 1280 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1408 KB Output is correct
13 Correct 5 ms 1280 KB Output is correct
14 Correct 11 ms 7036 KB Output is correct
15 Correct 6 ms 3968 KB Output is correct
16 Correct 8 ms 4480 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 12 ms 8060 KB Output is correct
19 Correct 10 ms 7168 KB Output is correct
20 Correct 10 ms 7932 KB Output is correct
21 Correct 12 ms 8060 KB Output is correct
22 Correct 11 ms 7932 KB Output is correct
23 Correct 11 ms 7932 KB Output is correct
24 Correct 12 ms 8060 KB Output is correct
25 Correct 9 ms 7168 KB Output is correct
26 Correct 11 ms 7932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 1408 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1280 KB Output is correct
8 Correct 5 ms 1408 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 5 ms 1280 KB Output is correct
11 Correct 5 ms 1408 KB Output is correct
12 Correct 5 ms 1408 KB Output is correct
13 Correct 5 ms 1280 KB Output is correct
14 Correct 11 ms 7036 KB Output is correct
15 Correct 6 ms 3968 KB Output is correct
16 Correct 8 ms 4480 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 12 ms 8060 KB Output is correct
19 Correct 10 ms 7168 KB Output is correct
20 Correct 10 ms 7932 KB Output is correct
21 Correct 12 ms 8060 KB Output is correct
22 Correct 11 ms 7932 KB Output is correct
23 Correct 11 ms 7932 KB Output is correct
24 Correct 12 ms 8060 KB Output is correct
25 Correct 9 ms 7168 KB Output is correct
26 Correct 11 ms 7932 KB Output is correct
27 Correct 188 ms 118204 KB Output is correct
28 Correct 14 ms 19584 KB Output is correct
29 Correct 16 ms 10108 KB Output is correct
30 Correct 6 ms 896 KB Output is correct
31 Correct 141 ms 87660 KB Output is correct
32 Correct 114 ms 95460 KB Output is correct
33 Correct 152 ms 120020 KB Output is correct
34 Correct 165 ms 114372 KB Output is correct
35 Correct 148 ms 120144 KB Output is correct
36 Correct 160 ms 120076 KB Output is correct
37 Correct 194 ms 120256 KB Output is correct
38 Correct 86 ms 79336 KB Output is correct
39 Correct 109 ms 87272 KB Output is correct