Submission #1289216

#TimeUsernameProblemLanguageResultExecution timeMemory
1289216Joon_YorigamiBitaro the Brave (JOI19_ho_t1)C++20
0 / 100
2 ms836 KiB
/* .:-=++***#***+=:. .:-==+**##**%########***#####*=:. .-+#%%#*****############**#******#####+=: .-*%#####********###########*********#######*+-: :+#######**********########*****+********##########+-. :+##########**###******##********************###########+: :+##########*****#*******###**********************###***####*: .=###########***###*******#***************************#****#####*: :*#################******************************************######= -###################***************+****************************#####*: .=###################******************************************#****#####+. :*###################*******************************+************#*****#####: =#############**######*****#*******************++***++++++***************#####= .*###########******####*****#************+++*+**+++***++++++++***#**********#####+ -############********###*****%*+****+++++++++++++++++***++++++++***#*****#****#####* =############********###+++++##++++++++++++++++*++++++****++++******##*+++*#****#####*. .+#*##########*********###+++++%*++==++++++++++++*+++++*#************#*##*+++##****#####*. .*#=-##########********###*++++*%*+++++++++++++*****+******#***********#*##*+++####*######*. .:-: .*#: *#########*********###+++++##****++*******************#*#**********##*#*****####*#%###%*. .--:++=+. .**. ##########********##*#++***%#****+*************=#*****#*#**********##*##*##*####**#%###%*: :++===== .**. -###########******##*##+****%#*****#************-********#**********#***%####*###***#%######=: .-=++= =*. +############****###*##*****%#*****%####*####**#:=#***#**#**********#=##*###**####***#%########+: . .#. .####################*##*****%#####*%#****##****#.:#***#*#**********#%:##*+##***%###***############+: -- -###################**#*****####****##****##*****..#*****#**********#*.*#+ +##**#####***##############+-. -=+++-. = +###################**#*****###**********#*#***#: .***#*#***********#:.*#- :**#*######***#######%%%####%%#=: .++====++ = ####################**##*****###***#+****#=#**** .+*###************+ ## +***######****##########+--+#%%%%+: .---:=+======+: +. ##################%#***#*****####****#**#+-####. .+###***##*******# .#: :***########***##%%%####%#=. .:=*%% ---==++=======+= -= .%#################%****#*****######-#*##*.=%#*. +=---:::.......: =: =**#########***#%%%%%%%%%%%=. .- :-:===========+= .#. :%################%%****#*****#####= :-+***#*=. .*#########%%#**#*=%%%%%%%%%%=. .---=========+= :*. -#################%%****#*****%#+-.-*#%%%@###*= +##########%%%***:+-#%%%#####*: .:=++++====+- =*.=###%############%@%****#*****#. =###%%%@@@+ ###########%%%%#*#: -*########= ..:::::-. +*+###%####%######%%+******#****#=##= -@@@@@@@+ =*###########%%%%##+ :*#######+ =%##+%####%######%+.******#*****%%#-:+@@@@%-=* +..###########%##%%%*. -####### %##=#####%###%%#%:=******#*****%*.**##*+=: . -+**####*=: - .=###############%%*: .+##### .%###%########%%%%:.#*****##*****= .+: . :-::.:--=++- : .-*##################+: :#### :##.*###########%@# #************+ .:.-==-- . +**###+*##############*: .*## -%- ############%@@-#*###*#=##***#. :. =*++*#**++*##############*- .## =# ############@@@######*#:###*##= :..+*++++***+++++*##############=.+# +: ###########%@%%%%######.=###### .=+#+++++++***+++++****############## .+ *##########%%%%%%######::######= =+++#*+++++++*#+++++******########### +: =%#%######%%%##%@######:-+######. .:------== :*++++**+++++++*#*+++++********####### -* :%%%%#####%%%##%%%#####***######* -=--------=: -*+++++++*++++++++*#**+++*=:=******+==* .*+ +%%%%###%%####%%%#####**+#######= -........:=: -++++++++++*#**##***+******++- .-******=. -*= *%%%%##%%%%%%%#%#####**++#######. :.........- .=#%%%######%##########%#+*******. .-++++*+ -*+ .*%%%%#%%#######%#####*++++######*: ......... :=#%@@%%%%%%#################*++*****=. .-++++ :**. :###%%%#%%########%####*++++*#######=-:.. -+#%%%###########################++++****#=. .-++ -*+ .######%%%%#########%###@@@%%%%######+...:----:. :*%################################%*+++++*+###- .+ :*+.=########%%%%###########%%%%%%%%######-........:------::.+%%%%%###############%#############%*+++++*.:*##+. . -+####****##%%%%%%%%###%########%%@%#####:.......:::::::...=@@%%%@###############%############%*+++++*. =##+ +#*##*****####%%%%##%%%%#########%@%#####:.....-:....:..::=*=++++############################%#*+++++ -##. =%**********#######%%###############%*#####=...=. . :-=-: .###############%#******####%#####+= +* *#************#############%%#######**+*%####-.- .-:=##############%*********##%#######=: .+. *#****************##**######%%%###*: ::*#####: -:: .-+####%%%####%*********#%##########*-: =#***********************######%*- .--:=:. =. :--: .-=*###%###*********#######*#######+- .#**************************###= .:. ::... .=. +***#%##*******#########***#######+: =##**************************: :-:--. .. .+..... + =******#%#####%##########***#####**# ####**********************+. . :#########+-=:.... -: +***********##%%#***######****##**** .#%####******************- *##########*:....... ...:. #**************##*********###*##**** :#%@%%%###************* =#*******####+....... :-. *#***************%************#%#**** .#**###%%%%%######****#. =#***********#=....:-. :*#****************##*************####* *#**#****#####%%%%##### =#*************+=: .=-::..:-*#*****************##*****************## -#***#*******######%%%%= :=*#**********: ... ##*##%##*******************#******************** .%*****#*********######%. ....:-=*- :++: =#****##%####*************###******************** :. +#*****#**********####%+ ..-*#***#+=##*******##%%###********####********************* .:-:. .%#*****#**********#%%%* :=+**##########******###********#%%%%%%##****###*********************** -- =%#******#*********@#%%-. :#%%%%%%%%%%%%%%###*****###*****#%%##%%%#%@#####************************* =-. .=. ##*******#********#%#**###*+=-:.: -######%##%###%####%%%%%##########%####%%%%##%*************####************ ==== .= :%#*******#********%%***************++#%%#%#######%###%#######%%%%%%%########%%%%####%#************####*********** ==== -: *%#*******#********@#********************#%#######%###%###########%%%%%#####%%%#######%%#**********#####********** :+=+. = .%###*******#******#%#*******************#%#############%##############%%%##%######***####%%#*******######********* */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> cheese; using ll = long long; using pll = pair<ll, ll>; using vll = vector<ll>; using mll = map<ll, ll>; using sll = set<ll>; using sc = set<char>; #define printv(v) {for(auto &elem:v){cout<<elem<<" ";}cout<<endl;} #define printg(g) {for(auto &row:g){printv(row)};} #define printm(m) {for(auto &pa:m){cout << pa.first << "," << pa.second << " ";};cout<<endl;} ll min(ll a,int b) { if (a<b) return a; return b; } ll min(int a,ll b) { if (a<b) return a; return b; } ll max(ll a,int b) { if (a>b) return a; return b; } ll max(int a,ll b) { if (a>b) return a; return b; } ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); } ll lcm(ll a,ll b) { return a/gcd(a,b)*b; } string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; } string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; } bool is_prime(ll a) { if(a==1) return false; for(ll i=2;i*i<=a;i++) { if (a%i==0) return false; } return true; } ll binpow(ll a, ll b, ll m) { a %= m; ll res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } ll moddiv(ll numerator,ll denominator, ll mod) { numerator %= mod; denominator %= mod; return numerator * binpow(denominator,mod-2,mod) % mod; } //DSU https://cp-algorithms.com/data_structures/disjoint_set_union.html const int DSUN = 200000; int parent[DSUN]; int set_size[DSUN]; int find_set(int v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]); } void make_set(int v) { parent[v] = v; set_size[v] = 1; } void union_sets(int a, int b) { a = find_set(a); b = find_set(b); if (a != b) { if (set_size[a] < set_size[b]) swap(a, b); parent[b] = a; set_size[a] += set_size[b]; } } //DSU //https://cp-algorithms.com/algebra/sieve-of-eratosthenes.html vector<char> segmentedSieve(ll L, ll R) { // generate all primes up to sqrt(R) ll lim = sqrt(R); vector<char> mark(lim + 1, false); vector<ll> primes; for (ll i = 2; i <= lim; ++i) { if (!mark[i]) { primes.emplace_back(i); for (ll j = i * i; j <= lim; j += i) mark[j] = true; } } vector<char> isPrime(R - L + 1, true); for (ll i : primes) for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i) isPrime[j - L] = false; if (L == 1) isPrime[0] = false; return isPrime; } //segtree vector<ll> builder(vector<ll> &arr) { ll identityelement = 0; vector<ll> segtree; ll n,segtree_size; n=arr.size(); segtree_size=1; while(segtree_size<n) { segtree_size<<=1; } segtree.assign(2*segtree_size,0); for(int i=0;i<n;i++) { segtree[segtree_size+i]=arr[i]; } for(int i=segtree_size-1;i>0;i--) { segtree[i]=segtree[i*2]+segtree[i*2+1]; } return segtree; } ll query_sum(vector<ll>&segtree,vector<ll>&lazy,ll query_l,ll query_r,ll val,ll node_l,ll node_r,ll node) { if(lazy[node]!=0) { segtree[node]+=(node_r-node_l+1)*lazy[node]; if(node_l!=node_r) { lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node]; } lazy[node]=0; } if(val!=-1 && query_l<=node_l && node_r<=query_r) { segtree[node]+=(node_r-node_l+1)*val; if(node_l!=node_r) { lazy[node*2]+=val; lazy[node*2+1]+=val; } lazy[node]=0; } if(query_l<=node_l && node_r<=query_r) { return segtree[node]; } else if(node_r<query_l || query_r<node_l) { return 0ll; } else { ll mid = node_l+(node_r-node_l)/2; ll sum = query_sum(segtree,lazy,query_l,query_r,val,node_l,mid,node*2)+query_sum(segtree,lazy,query_l,query_r,val,mid+1,node_r,node*2+1); segtree[node] = segtree[node*2]+segtree[node*2+1]; return sum; } return 0ll; } //segtree ll kadane(vll &a) { ll ans = a[0], sum = 0; for (int r = 0; r < a.size(); r++) { sum += a[r]; ans = max(ans, sum); sum = max(sum, 0); } return ans; } vector<bool>sieve(ll n) { vector<bool>ret(n+1,true); ret[0]=false; ret[1]=false; for(ll i=2;i<=n;i++) { if(ret[i]) { for(ll j=i*i;j<=n;j+=i) { ret[j]=false; } } } return ret; } ll dp[3000][3000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); /* vll segtree,lazy; ll segtree_size; segtree=builder(arr); segtree_size=segtree.size()/2; lazy.assign(segtree_size*2,0); update: query_sum(segtree,lazy,a,b,c,1,segtree_size,1); query: cout << query_sum(segtree,lazy,a,b,-1,1,segtree_size,1) << endl; */ ll n,m; cin >> n >> m; vector<string> grid; for(int i=0;i<n;i++) { string s; cin >> s; grid.push_back(s); } for(int i=0;i<n;i++) { ll cnto=0; for(int j=m-1;j>=0;j--) { if(grid[i][j]=='O') { cnto+=1; continue; } if(grid[i][j]=='J') { dp[i][j]=cnto; } } } for(int j=0;j<n;j++) { ll cnti=0; for(int i=n-1;i>=0;i--) { if(grid[i][j]=='I') { cnti+=1; continue; } if(grid[i][j]=='J') { dp[i][j]*=cnti; } } } ll ans=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++) ans+=dp[i][j]; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...