This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> h(n), w(n);
int cnt = 0;
for(int i = 0; i < n; i++){
cin >> h[i] >> w[i];
cnt += w[i];
}
if(h[0] > 1 && cnt > 1) cout << cnt * (cnt - 1) / 2 * h[0] * (h[0] - 1) / 2 << endl;
else if(h[0] == 1 && cnt != 1) cout << cnt * (cnt - 1) / 2 << endl;
else if(cnt == 1 && h[0] != 1) cout << h[0] * (h[0] - 1) / 2 << endl;
else cout << 1 << endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |