Submission #230214

#TimeUsernameProblemLanguageResultExecution timeMemory
230214AMO5Bitaro the Brave (JOI19_ho_t1)C++98
0 / 100
6 ms640 KiB
// READ & UNDERSTAND // ll, int overflow, array bounds, memset(0) // special cases (n=1?), n+1 (1-index) // do smth instead of nothing & stay organized // WRITE STUFF DOWN #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define MOD 1000000007 typedef long long ll; typedef pair <int, int> ii; typedef pair <ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef long double ld; ll INF=LLONG_MAX; int const mxn=3e3+3; string s[mxn]; vi orb[mxn],ing[mxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int h,w; cin >> h >> w; for(int i=0; i<h; i++)cin >> s[i]; vector<ii>J; for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(s[i][j]=='J')J.pb(ii(i,j)); else if(s[i][j]=='O')orb[i].pb(j); else ing[j].pb(i); } } ll ans=0; for(ii j:J){ int x = j.fi; int y = j.se; auto ptrx = lower_bound(all(orb[x]),y)-orb[x].begin(); auto ptry = lower_bound(all(ing[y]),x)-ing[y].begin(); int szx = (int)orb[x].size(); int szy = (int)orb[y].size(); ans += ll(szx-ptrx)*(szy-ptry) ; } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...