#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long h, w;
cin >> h >> w;
vector<pair<long long, long long>> joia;
map<long long, vector<long long>> orbe;
map<long long, vector<long long>> ingo;
for (long long i = 1; i <= h; i++)
{
for (long long j = 1; j <= w; j++)
{
char x;
cin >> x;
if (x == 'J')
{
joia.push_back({i, j});
}
if (x == 'O')
{
if (orbe.find(i) == orbe.end())
{
vector<long long> k;
orbe[i] = k;
}
orbe[i].push_back(j);
}
if (x == 'I')
{
if (ingo.find(j) == orbe.end())
{
vector<long long> k;
ingo[j] = k;
}
ingo[j].push_back(i);
}
}
}
long long ans = 0;
long long a= 0, b= 0;
for (auto k : joia)
{
a = 0;
b = 0;
//cout << "( " << k.first << " , " << k.second << " )\n";
//cout << "l: ";
for (auto o : orbe[k.first])
{
//cout << o << " ";
if (k.second < o) a++;
}
//cout << "\n";
//cout << "k: ";
for (auto i : ingo[k.second])
{
//cout << i << " ";
if (k.first < i) b++;
}
if (ingo[k.second].size() == 0 || orbe[k.first].size() == 0)
{
a = 0;
b = 0;
}
//cout << "\n";
//cout << a << ", " << b << "\n";
ans += a*b;
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
37 ms |
2888 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
17 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
49 ms |
4272 KB |
Output is correct |
19 |
Correct |
23 ms |
3148 KB |
Output is correct |
20 |
Correct |
47 ms |
3084 KB |
Output is correct |
21 |
Correct |
55 ms |
4296 KB |
Output is correct |
22 |
Correct |
37 ms |
3656 KB |
Output is correct |
23 |
Correct |
47 ms |
2996 KB |
Output is correct |
24 |
Correct |
50 ms |
3528 KB |
Output is correct |
25 |
Correct |
21 ms |
3020 KB |
Output is correct |
26 |
Correct |
47 ms |
3056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
37 ms |
2888 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
17 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
49 ms |
4272 KB |
Output is correct |
19 |
Correct |
23 ms |
3148 KB |
Output is correct |
20 |
Correct |
47 ms |
3084 KB |
Output is correct |
21 |
Correct |
55 ms |
4296 KB |
Output is correct |
22 |
Correct |
37 ms |
3656 KB |
Output is correct |
23 |
Correct |
47 ms |
2996 KB |
Output is correct |
24 |
Correct |
50 ms |
3528 KB |
Output is correct |
25 |
Correct |
21 ms |
3020 KB |
Output is correct |
26 |
Correct |
47 ms |
3056 KB |
Output is correct |
27 |
Execution timed out |
1097 ms |
110692 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |