제출 #114263

#제출 시각아이디문제언어결과실행 시간메모리
114263abacabaBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
875 ms75060 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...