Submission #1108150

#TimeUsernameProblemLanguageResultExecution timeMemory
1108150TsaganaStar triangles (IZhO11_triangle)C++17
0 / 100
4 ms592 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; vector<pair<int, int>> vx; vector<pair<int, int>> vy; vector<pair<int, int>> p; int X[300001]; int Y[300001]; void solve () { int n; cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; vx.pb({x, i}); vy.pb({y, i}); p.pb({x, y}); } sort(all(vx)); sort(all(vy)); int l = 0; p[vx[0].S].F = 0; for (int i = 1; i < n; i++) { if (vx[i].F != vx[i-1].F) l++; p[vx[i].S].F = l; } int r = 0; p[vy[0].S].S = 0; for (int i = 1; i < n; i++) { if (vy[i].F != vy[i-1].F) r++; p[vy[i].S].S = r; } for (auto i: p) { X[i.F]++; Y[i.S]++; } int ans = 0; for (auto i: p) { ans += (X[i.F]-1)*(Y[i.S]-1); } cout << ans; } signed main() { IOS #ifndef LOCAL freopen("triangles.in", "r", stdin); freopen("triangles.out", "w", stdout); #endif solve(); return 0; }

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   freopen("triangles.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   freopen("triangles.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...