Submission #1112585

#TimeUsernameProblemLanguageResultExecution timeMemory
1112585ChinguunStar triangles (IZhO11_triangle)C++14
100 / 100
391 ms15432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; int n, x, y, ans; map <int, vi> mp; map <int, pii> p; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> x >> y; mp[x].pb (y); p[y].ff++; } for (auto it : mp) { vi v = it.ss; for (int i = 0; i < v.size (); i++) { ans += i * (p[v[i]].ss + p[v[i]].ff - 1); ans += (v.size () - i - 1) * (p[v[i]].ss + p[v[i]].ff - 1); p[v[i]].ff--; p[v[i]].ss++; } } cout << ans; return 0; }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:29:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int i = 0; i < v.size (); i++) {
      |                   ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...