Submission #671594

# Submission time Handle Problem Language Result Execution time Memory
671594 2022-12-13T09:12:38 Z Cutebol Star triangles (IZhO11_triangle) C++17
100 / 100
275 ms 9084 KB
#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

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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 5 ms 1108 KB Output is correct
13 Correct 5 ms 1108 KB Output is correct
14 Correct 9 ms 1472 KB Output is correct
15 Correct 102 ms 5764 KB Output is correct
16 Correct 105 ms 5868 KB Output is correct
17 Correct 94 ms 5744 KB Output is correct
18 Correct 101 ms 5692 KB Output is correct
19 Correct 260 ms 8764 KB Output is correct
20 Correct 200 ms 7616 KB Output is correct
21 Correct 272 ms 9084 KB Output is correct
22 Correct 275 ms 9080 KB Output is correct