Submission #816597

# Submission time Handle Problem Language Result Execution time Memory
816597 2023-08-09T05:49:32 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
220 ms 88520 KB
#include<bits/stdc++.h>
 
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
  os << '{';
  bool osu = 1;
  for(auto &i : v) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const deque<T> &v) {
  os << '{';
  bool osu = 1;
  for(auto &i : v) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}
template<class T,long long unsigned int size>
ostream& operator<<(ostream& os, const array<T,size> &arr) {
  os << '{';
  bool osu = 1;
  for(auto &i : arr) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}
 
#define ll long long
#define ull unsigned long long
#define lll __int128
#define rep(i,n,N) for(int i=(n);i<=(N);++i)
#define For(i,n,N) for(int i=(n);i< (N);++i)
#define rap(i,n,N) for(int i=(n);i>=(N);--i)
#define rip(i,n,N,V) for(int i=(n);i<=(N);i+=V)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
//#define le left
//#define ri right
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define debug(x) cout << #x << " -> " << (x) << endl
#define out(x,y) cout << ">> " << (x) << " " << (y) << endl
#define ou3(x,y,z) cout << ">> " << (x) << " " << (y) << " " << (z) << endl
#define mems(x,y) memset(&x,y,sizeof x)
#define memsv(x,y) memset(&x[0], y, sizeof(x[0]) * x.size())
#define popcount __builtin_popcountll
#define clz(x) (1<<(31-__builtin_clz(x)))
#define clzll(x) (1LL<<(63-__builtin_clzll(x)))
#define all(x) x.begin(),x.end()
#define rsort(x) sort(x), reverse(x)
#define revsort(a,b) sort(a,b), reverse(a,b)
#define PQ(T) priority_queue<T>
#define PQr(T) priority_queue<T, vector<T>, greater<T>>
#define permute(x) while(next_permutation(all(x)))
#define distinct(x) x.erase(unique(all(x)),x.end())
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vll vector<ll>
#define vlll vector<pll>
#define vvll vector<vll>
#define ari(x) array<int,x>
#define arll(x) array<ll,x>
#define ard(x) array<double,x>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 3e3+5;
const int MOD = 1000000007;
const ll MOD2 = 2010405347;
const ll INF = 2e18;
const int dr[]={1,-1,0,0,1,1,-1,-1};
const int dc[]={0,0,-1,1,1,-1,1,-1};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 500;
inline ll pw(ll x,ll y,ll md=MOD){ll ret=1;x%=md;while(y){if(y&1)ret=ret*x%md;x=x*x%md,y>>=1;}return ret;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,y[MAX][MAX],z[MAX][MAX];
ll ans;
char x[MAX][MAX];

int main(){
//	cout<<fixed<<setprecision(10);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	rep(i,1,n)rep(j,1,m)cin>>x[i][j];
	rap(i,n,1)rap(j,m,1){
		y[i][j] = y[i][j+1];
		z[i][j] = z[i+1][j];
		if(x[i][j]=='O')++y[i][j];
		else if(x[i][j]=='I')++z[i][j];
	}
	rep(i,1,n)rep(j,1,m)if(x[i][j]=='J')ans+= y[i][j]*z[i][j];
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1368 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1368 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 7520 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 3 ms 4308 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 8 ms 8044 KB Output is correct
19 Correct 7 ms 7880 KB Output is correct
20 Correct 7 ms 7772 KB Output is correct
21 Correct 8 ms 8028 KB Output is correct
22 Correct 8 ms 7904 KB Output is correct
23 Correct 9 ms 7776 KB Output is correct
24 Correct 11 ms 8004 KB Output is correct
25 Correct 6 ms 7924 KB Output is correct
26 Correct 5 ms 7860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 2 ms 1368 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 7520 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 3 ms 4308 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 8 ms 8044 KB Output is correct
19 Correct 7 ms 7880 KB Output is correct
20 Correct 7 ms 7772 KB Output is correct
21 Correct 8 ms 8028 KB Output is correct
22 Correct 8 ms 7904 KB Output is correct
23 Correct 9 ms 7776 KB Output is correct
24 Correct 11 ms 8004 KB Output is correct
25 Correct 6 ms 7924 KB Output is correct
26 Correct 5 ms 7860 KB Output is correct
27 Correct 201 ms 87924 KB Output is correct
28 Correct 11 ms 25952 KB Output is correct
29 Correct 10 ms 7800 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 153 ms 72524 KB Output is correct
32 Correct 144 ms 88436 KB Output is correct
33 Correct 146 ms 88236 KB Output is correct
34 Correct 173 ms 84068 KB Output is correct
35 Correct 129 ms 88444 KB Output is correct
36 Correct 149 ms 88160 KB Output is correct
37 Correct 220 ms 88520 KB Output is correct
38 Correct 121 ms 72512 KB Output is correct
39 Correct 126 ms 72316 KB Output is correct