Submission #867675

#TimeUsernameProblemLanguageResultExecution timeMemory
867675sleepntsheepStar triangles (IZhO11_triangle)C++17
100 / 100
98 ms4088 KiB
#include <iostream> #include <unordered_map> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,tune=native") using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); using ll = long long; #define N 300005 int n; array<int, 2> a[N]; ll z; unordered_map<int, int> b; int main() { ShinLena; for (int i = (cin >> n, 0); i < n; ++i) cin >> a[i][0] >> a[i][1], ++b[a[i][1]]; sort(a, a+n); n = unique(a, a+n) - a; ll d=0; for (int f, e = 0, i = 0, l = -1; i < n; ++i) { f = a[i][0] == l; l += (a[i][0] - l) * !f, d *= f, e *= f; z += d + (b[a[i][1]] - 1ll) * e; ++e, d += b[a[i][1]] - 1; } cout << z; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...