Submission #524232

# Submission time Handle Problem Language Result Execution time Memory
524232 2022-02-08T20:25:52 Z ezdp Star triangles (IZhO11_triangle) C++14
100 / 100
460 ms 13488 KB
#pragma GCC target ("sse4")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define endl '\n'
#define pb push_back
#define fr first
#define sc second
#define ll long long int
#define ld long double
#define lsb(idx) idx&(-idx)
#define bin(x) bitset<32>(x).to_string()
#define all(A) A.begin(), A.end()
#define de(x) cout << #x << " = " << x << endl;

using namespace std;
using namespace __gnu_pbds;

template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using matrix = vector<vector<T>>;
/// find_by_order(x) -> x-th element in the set
/// order_of_key(x)  -> how many elements are less than x
/// insert(x)		 -> inserts x into the set

ll n, ans = 0;
vector<pair<int, int>> v;
map<int, int> mp_x, mp_y;

int main(){
	/// ios_base::sync_with_stdio(false); cin.tie(NULL);
	/// freopen("filename.in" , "r", stdin); 
	/// freopen("filename.out", "w", stdout);
	cin >> n;
	for(int i = 0; i < n; i ++){
		int x, y; cin >> x >> y;
		++ mp_x[x];
		++ mp_y[y];
		v.pb({x, y});
	}
	for(auto [x, y] : v){
		ans += (mp_x[x] - 1) * (mp_y[y] - 1);
	}
	cout << ans << endl;
}
/**

*/

Compilation message

triangle.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("O3")
      | 
triangle.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("unroll-loops")
      | 
triangle.cpp: In function 'int main()':
triangle.cpp:44:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |  for(auto [x, y] : v){
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 0 ms 280 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 288 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 12 ms 956 KB Output is correct
13 Correct 12 ms 944 KB Output is correct
14 Correct 15 ms 1344 KB Output is correct
15 Correct 159 ms 6048 KB Output is correct
16 Correct 188 ms 6372 KB Output is correct
17 Correct 151 ms 6100 KB Output is correct
18 Correct 168 ms 6196 KB Output is correct
19 Correct 413 ms 13284 KB Output is correct
20 Correct 310 ms 9164 KB Output is correct
21 Correct 443 ms 13312 KB Output is correct
22 Correct 460 ms 13488 KB Output is correct