Submission #753098

#TimeUsernameProblemLanguageResultExecution timeMemory
753098CdSBitaro the Brave (JOI19_ho_t1)C++17
50 / 100
1097 ms110692 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...