#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const double PI = 4 * atan(1);
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>
#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
void fast_io(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
void io(string taskname){
string fin = taskname + ".in";
string fout = taskname + ".out";
const char* FIN = fin.c_str();
const char* FOUT = fout.c_str();
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
fast_io();
}
const int MAX = 3e3 + 5;
int orb[MAX][MAX];
int ingot[MAX][MAX];
vpi jewel;
int main(){
fast_io();
int h, w;
cin >> h >> w;
string temporary;
getline(cin, temporary);
f0r(i, h){
string s;
getline(cin, s);
f0r(j, w){
if(s[j] == 'J'){
jewel.eb(mp(i, j));
}
else if(s[j] == 'O'){
orb[i][j]++;
}
else{
ingot[i][j]++;
}
}
}
f0r(i, h){
f1r(j,1, w){
orb[i][j] += orb[i][j-1];
}
}
f0r(i, w){
f1r(j,1, h){
ingot[j][i] += ingot[j-1][i];
}
}
ll ans = 0;
for(auto p: jewel){
int i = p.f;
int j = p.s;
ll v1 = orb[i][w-1] - orb[i][j];
ll v2 = ingot[h-1][j] - ingot[i][j];
ans += v1*v2;
}
cout << ans << endl;
return 0;
}
Compilation message
joi2019_ho_t1.cpp:1:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/stack:200000000")
joi2019_ho_t1.cpp: In function 'void io(std::__cxx11::string)':
joi2019_ho_t1.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FIN, "r", stdin);
~~~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen(FOUT, "w", stdout);
~~~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
3 ms |
1272 KB |
Output is correct |
7 |
Correct |
3 ms |
1148 KB |
Output is correct |
8 |
Correct |
3 ms |
1272 KB |
Output is correct |
9 |
Correct |
3 ms |
1272 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1272 KB |
Output is correct |
12 |
Correct |
3 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
3 ms |
1272 KB |
Output is correct |
7 |
Correct |
3 ms |
1148 KB |
Output is correct |
8 |
Correct |
3 ms |
1272 KB |
Output is correct |
9 |
Correct |
3 ms |
1272 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1272 KB |
Output is correct |
12 |
Correct |
3 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1144 KB |
Output is correct |
14 |
Correct |
10 ms |
6744 KB |
Output is correct |
15 |
Correct |
5 ms |
3832 KB |
Output is correct |
16 |
Correct |
8 ms |
4056 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
13 ms |
7276 KB |
Output is correct |
19 |
Correct |
10 ms |
6780 KB |
Output is correct |
20 |
Correct |
11 ms |
7148 KB |
Output is correct |
21 |
Correct |
12 ms |
7404 KB |
Output is correct |
22 |
Correct |
12 ms |
7280 KB |
Output is correct |
23 |
Correct |
18 ms |
7280 KB |
Output is correct |
24 |
Correct |
13 ms |
7536 KB |
Output is correct |
25 |
Correct |
10 ms |
6776 KB |
Output is correct |
26 |
Correct |
12 ms |
7276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
1272 KB |
Output is correct |
6 |
Correct |
3 ms |
1272 KB |
Output is correct |
7 |
Correct |
3 ms |
1148 KB |
Output is correct |
8 |
Correct |
3 ms |
1272 KB |
Output is correct |
9 |
Correct |
3 ms |
1272 KB |
Output is correct |
10 |
Correct |
4 ms |
1272 KB |
Output is correct |
11 |
Correct |
3 ms |
1272 KB |
Output is correct |
12 |
Correct |
3 ms |
1272 KB |
Output is correct |
13 |
Correct |
3 ms |
1144 KB |
Output is correct |
14 |
Correct |
10 ms |
6744 KB |
Output is correct |
15 |
Correct |
5 ms |
3832 KB |
Output is correct |
16 |
Correct |
8 ms |
4056 KB |
Output is correct |
17 |
Correct |
3 ms |
504 KB |
Output is correct |
18 |
Correct |
13 ms |
7276 KB |
Output is correct |
19 |
Correct |
10 ms |
6780 KB |
Output is correct |
20 |
Correct |
11 ms |
7148 KB |
Output is correct |
21 |
Correct |
12 ms |
7404 KB |
Output is correct |
22 |
Correct |
12 ms |
7280 KB |
Output is correct |
23 |
Correct |
18 ms |
7280 KB |
Output is correct |
24 |
Correct |
13 ms |
7536 KB |
Output is correct |
25 |
Correct |
10 ms |
6776 KB |
Output is correct |
26 |
Correct |
12 ms |
7276 KB |
Output is correct |
27 |
Correct |
235 ms |
101296 KB |
Output is correct |
28 |
Correct |
20 ms |
19448 KB |
Output is correct |
29 |
Correct |
16 ms |
9060 KB |
Output is correct |
30 |
Correct |
3 ms |
760 KB |
Output is correct |
31 |
Correct |
193 ms |
81596 KB |
Output is correct |
32 |
Correct |
143 ms |
86444 KB |
Output is correct |
33 |
Correct |
197 ms |
103008 KB |
Output is correct |
34 |
Correct |
208 ms |
99512 KB |
Output is correct |
35 |
Correct |
188 ms |
102528 KB |
Output is correct |
36 |
Correct |
229 ms |
102908 KB |
Output is correct |
37 |
Correct |
247 ms |
108016 KB |
Output is correct |
38 |
Correct |
113 ms |
70436 KB |
Output is correct |
39 |
Correct |
139 ms |
81340 KB |
Output is correct |