이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
const int inf = 2e9;
const int N = 3e3 + 15;
int n, m, a[N];
vector <int> O[N], I[N];
vector <pii> is;
ll ans;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("input.txt", "r", stdin);
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
char c;
cin >> c;
if(c == 'J')
is.pb(mp(i, j));
else if(c == 'O')
O[i].pb(j);
else
I[j].pb(i);
}
}
for(int i = 0; i < N; ++i) {
sort(O[i].begin(), O[i].end());
sort(I[i].begin(), I[i].end());
}
for(auto i : is) {
ll val1 = O[i.f].end() - upper_bound(O[i.f].begin(), O[i.f].end(), i.se);
ll val2 = I[i.se].end() - upper_bound(I[i.se].begin(), I[i.se].end(), i.f);
ans += val1 * val2;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |