Submission #671594

#TimeUsernameProblemLanguageResultExecution timeMemory
671594CutebolStar triangles (IZhO11_triangle)C++17
100 / 100
275 ms9084 KiB
#include <bits/stdc++.h>

using namespace std;

void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
#define Xiao ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
#define int long long
#define endl "\n"
#define ff first
#define ss second
  
const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;

int n ;
int x[N] , y[N] ;
map <int , int> mpx , mpy ;

void solve(){
	
	cin >> n ;
	for ( int i = 0 ; i < n ; i ++ ){
		int xx, yx ;
		cin >> x[i] >> y[i] ;
		mpx[x[i]] ++ ;
		mpy[y[i]] ++ ;
	}
	int ans = 0 ;
	for ( int i = 0 ; i < n ; i ++ ){
		ans += (mpx[x[i]]-1)*(mpy[y[i]]-1) ;
	}
	cout << ans ;
}

signed main(){
    Xiao ;
    int t = 1 ;
//  	cin >> t ;
	while ( t -- ) solve() ; 
}

Compilation message (stderr)

triangle.cpp: In function 'void solve()':
triangle.cpp:24:7: warning: unused variable 'xx' [-Wunused-variable]
   24 |   int xx, yx ;
      |       ^~
triangle.cpp:24:11: warning: unused variable 'yx' [-Wunused-variable]
   24 |   int xx, yx ;
      |           ^~
triangle.cpp: In function 'void fopn(std::string)':
triangle.cpp:5:31: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:5:72: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | void fopn(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...