Submission #45509

# Submission time Handle Problem Language Result Execution time Memory
45509 2018-04-14T20:56:24 Z rkocharyan Star triangles (IZhO11_triangle) C++14
0 / 100
834 ms 132056 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>	
#include <ctime>
#include <map>
#include <unordered_map>
#include <stack>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <bitset>
#include <limits>
#include <climits>
#include <queue>
#include <deque>
#include <list>
#include <forward_list>
#include <complex>
#include <sstream>
#include <cassert>
#include <functional>
#include <tuple>
#include <array> 
#include <locale>
#include <cstdio>
#include <memory>
//#include <bits/stdc++.h>
using namespace std;

#define Fin freopen("input.txt", "r", stdin);
#define Fout freopen("output.txt", "w", stdout);
#define cp(x) cout.setf(ios::fixed); cout.precision(x);
#define rep(i, x, n) for(int i = x; i <= n; ++i)
#define add push_back
#define del pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
#pragma GCC optimize("unroll-loops")
//define DEBUG

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;

typedef map <int, int> mii;
typedef unordered_map <int, int> umpii;
typedef pair <int, int> pii;
typedef vector <int> lnum;
typedef vector <int> vi;
typedef vector < vector <int> > vii;
typedef priority_queue <int> pqi;

inline int nxt() { int x; scanf("%d", &x); return x; }
inline long long lnxt() { long long x; scanf("%I64d", &x); return x; }

//mt19937 gen(time(NULL));
const int base = (int)1e9;
const int N = (int)1e6 + 100;
const int MAXN = (int)1e3 + 100;
const int MOD = (int)1e9 + 7;
const int INF = INT_MAX;
const long long LL_INF = LLONG_MAX;
const long double PI = acos((ld)-1.0);
const long double EPS = 1e-8;

long long cnt = 0, ans = 0;

#define int int64_t

unordered_map <int, int> X, Y;

void solve() {
	int n; cin >> n;
	vector < pair <int, int> > V;
	for (int i = 0; i < n; ++i) {
		int x, y; cin >> x >> y;
		V.add(make_pair(x, y));
		X[x]++;
		Y[y]++;
	}
	for (int i = 0; i < n; ++i) {
		int x, y; tie(x, y) = V[i];
		ans += max((ll)X[x] - 1, (ll)0) * max((ll)Y[y] - 1, (ll)0);
	}
	cout << ans << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	#define FREOPEN
#ifdef FREOPEN
#ifndef _MSC_VER 
#define TASK "triangles"
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
#endif

	//Fin; Fout;

	int T = 1;
	//scanf("%d", &T);

	for (; T; --T) solve();

#ifdef DEBUG
	cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif 

	return 0;
}

Compilation message

triangle.cpp:42:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
triangle.cpp: In function 'long long int lnxt()':
triangle.cpp:60:57: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
 inline long long lnxt() { long long x; scanf("%I64d", &x); return x; }
                                                       ~~^
triangle.cpp: In function 'int32_t main()':
triangle.cpp:101:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen(TASK".in", "r", stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:102:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen(TASK".out", "w", stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 834 ms 132056 KB Output isn't correct
2 Halted 0 ms 0 KB -