Submission #974886

#TimeUsernameProblemLanguageResultExecution timeMemory
974886vjudge1Star triangles (IZhO11_triangle)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int n; long long count(const vector<pair<int, int>> &points) { long long count = 0; int n = points.size(); map<int, int> rowCount; for (const auto &point : points) { rowCount[point.second]++; } for (int i = 0; i < n; ++i) { int x1 = points[i].first; int y1 = points[i].second; map<int, int> rightCount; for (int j = i + 1; j < n; ++j) { int x2 = points[j].first; int y2 = points[j].second; if (y2 == y1) { rightCount[x2]++; } } for (auto &row : rowCount) { int y2 = row.first; int countOnRow = row.second; if (y2 <= y1) { count += (countOnRow - 1) * rightCount[y2]; } else { count += countOnRow * rightCount[y2]; } } } return count; } void solve() { cin >> n; vector<pair<int, int>> point(n); for (int i = 0; i < n; i++) { cin >> point[i].first >> point[i].second; } cout << count(point); } int main() { int t = 1; while (t--) { solve(); } }

Compilation message (stderr)

triangle.cpp: In function 'long long int count(const std::vector<std::pair<int, int> >&)':
triangle.cpp:20:13: warning: unused variable 'x1' [-Wunused-variable]
   20 |         int x1 = points[i].first;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...