Submission #337506

#TimeUsernameProblemLanguageResultExecution timeMemory
337506tengiz05Star triangles (IZhO11_triangle)C++17
100 / 100
1036 ms28384 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define PI acos(-1) #define ld long double const int mod = 1e9+7, N = 2e5+5; int msb(int val){return sizeof(int)*8-__builtin_clzll(val);} int a[N], n, m, k; map<int, vector<int>> X, Y; void solve(int test_case){ int i, j; cin >> n; vector<pii> tmp; for(i=0;i<n;i++){ int x, y; cin >> x >> y; Y[x].pb(y); X[y].pb(x); tmp.pb({x, y}); } int ans = 0; for(auto &[t, tt] : X)sort(all(tt)); for(auto &[t, tt] : Y)sort(all(tt)); for(auto [x, y] : tmp){ int itx = lower_bound(all(X[y]), x)-X[y].begin(); int ity = lower_bound(all(Y[x]), y)-Y[x].begin(); int bx = X[y].size()-itx-1; int by = Y[x].size()-ity-1; ans += bx*by; ans += bx*ity; ans += itx*by; ans += itx*ity; } cout << ans << '\n'; return; } signed main(){ FASTIO; #define MULTITEST 0 #if MULTITEST int ___T; cin >> ___T; for(int T_CASE = 1; T_CASE <= ___T; T_CASE++) solve(T_CASE); #else solve(1); #endif return 0; }

Compilation message (stderr)

triangle.cpp: In function 'void solve(long long int)':
triangle.cpp:17:9: warning: unused variable 'j' [-Wunused-variable]
   17 |  int i, j;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...