Submission #879931

#TimeUsernameProblemLanguageResultExecution timeMemory
879931heeheeheehaawStar triangles (IZhO11_triangle)C++17
100 / 100
420 ms10172 KiB
#include <bits/stdc++.h> #define int long long using namespace std; map<int, vector<int>> aux; vector<int> v; map<int, int> fr; signed main() { int n; cin>>n; for(int i = 1; i <= n; i++) { int x, y; cin>>x>>y; aux[x].push_back(y); fr[y]++; } int rez = 0; for(auto i : aux) { v = i.second; sort(v.begin(), v.end()); int cnt = -1; for(int j = 0; j < v.size(); j++) { cnt++; rez += cnt * (fr[v[j]] - 1); } cnt = -1; for(int j = (int)v.size() - 1; j >= 0; j--) { cnt++; rez += cnt * (fr[v[j]] - 1); } } cout<<rez; return 0; }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:28:26: 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]
   28 |         for(int j = 0; j < v.size(); j++)
      |                        ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...