답안 #491748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491748 2021-12-04T08:55:32 Z ssense Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
502 ms 18120 KB
#include <bits/stdc++.h>
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long  ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define nax 200005
#define pb push_back
#define sc second
#define fr first
#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}struct prefix_sum{vint pref;void build(vint a){pref.pb(0);for(int i = 0; i < a.size(); i++){pref.pb(pref.back()+a[i]);}}int get(int l, int r){return pref[r]-pref[l-1];}};//ssense

/*
	
 */

void solve()
{
	int n, m;
	cin >> n >> m;
	char a[n][m];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	map<int, int> arrangements;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int now = 0;
		for(int j = m-1; j >= 0; j--)
		{
			if(a[i][j] == 'O')
			{
				now++;
			}
			if(a[i][j] == 'J')
			{
				arrangements[j]+=now;
			}
			if(a[i][j] == 'I')
			{
				ans+=arrangements[j];
			}
		}
	}
	cout << ans << endl;
}

int32_t main(){
	startt
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
}
/*
 3 4
 JOIJ
 JIOO
 IIII
 
 
 */

Compilation message

joi2019_ho_t1.cpp: In member function 'void prefix_sum::build(std::vector<long long int>)':
joi2019_ho_t1.cpp:21:667: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | int ceildiv(int one, int two) {if (one % two == 0) {return one / two;}else {return one / two + 1;}} int power(int n, int pow, int m) {if (pow == 0) return 1;if (pow % 2 == 0) {ll x = power(n, pow / 2, m);return (x * x) % m;}else return (power(n, pow - 1, m) * n) % m;} int gcd(int a, int b) { if (!b)return a; return gcd(b, a % b);} int factorial(int n, int mod) {if (n > 1)return (n * factorial(n - 1, mod)) % mod; else return 1;} int lcm(int a, int b) {return (a * b) / gcd(a, b);} vector<int> read(int n) {vector<int> a; for (int i = 0; i < n; i++) { int x; cin >> x; a.pb(x);} return a;}struct prefix_sum{vint pref;void build(vint a){pref.pb(0);for(int i = 0; i < a.size(); i++){pref.pb(pref.back()+a[i]);}}int get(int l, int r){return pref[r]-pref[l-1];}};//ssense
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 11 ms 588 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 4 ms 588 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 17 ms 856 KB Output is correct
19 Correct 7 ms 716 KB Output is correct
20 Correct 8 ms 748 KB Output is correct
21 Correct 17 ms 828 KB Output is correct
22 Correct 8 ms 716 KB Output is correct
23 Correct 7 ms 716 KB Output is correct
24 Correct 13 ms 716 KB Output is correct
25 Correct 6 ms 776 KB Output is correct
26 Correct 7 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 11 ms 588 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 4 ms 588 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 17 ms 856 KB Output is correct
19 Correct 7 ms 716 KB Output is correct
20 Correct 8 ms 748 KB Output is correct
21 Correct 17 ms 828 KB Output is correct
22 Correct 8 ms 716 KB Output is correct
23 Correct 7 ms 716 KB Output is correct
24 Correct 13 ms 716 KB Output is correct
25 Correct 6 ms 776 KB Output is correct
26 Correct 7 ms 792 KB Output is correct
27 Correct 483 ms 17100 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 27 ms 1708 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 344 ms 12668 KB Output is correct
32 Correct 343 ms 17984 KB Output is correct
33 Correct 343 ms 17956 KB Output is correct
34 Correct 394 ms 14536 KB Output is correct
35 Correct 391 ms 17860 KB Output is correct
36 Correct 325 ms 18016 KB Output is correct
37 Correct 502 ms 18120 KB Output is correct
38 Correct 158 ms 12496 KB Output is correct
39 Correct 241 ms 12660 KB Output is correct