답안 #164659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164659 2019-11-22T11:23:54 Z ahmet 별들과 삼각형 (IZhO11_triangle) C++14
0 / 100
4 ms 504 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const long long mx=3e5+5;
// FREOPEN UNUTMA
long long n;
pair <long long,long long>  a[mx];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	freopen("triangles.in", "r", stdin);
	freopen("triangles.out", "w", stdout); 
   //
	unordered_map <long long,long long> mp;
	unordered_map <long long,long long> mp2;	
	cin >> n;
	rep(i,n){
		cin >> a[i].first;
		cin >> a[i].second;
		mp.insert(pair <long long,long long>(a[i].first,a[i].nd));
		mp2.insert(pair<long long,long long>(a[i].nd,a[i].st));
	}
	long long ans=0;
	for(long long i=0;i<n;++i){
		ans+=(mp.count(a[i].first)-1)*(mp2.count(a[i].nd)-1);
	//	cout << mp.count(a[i].first) <<" "<< mp2.count(a[i].nd)<< endl;
	}
	cout << ans << endl;
}  	

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("triangles.in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:18:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("triangles.out", "w", stdout); 
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -