Submission #89788

# Submission time Handle Problem Language Result Execution time Memory
89788 2018-12-18T12:15:11 Z Atashka01 Star triangles (IZhO11_triangle) C++11
0 / 100
2000 ms 26460 KB
//Euzibillahiminesseytanirracim Bismillahirrahmanirrahim

/*
ID:
TASK:
LANG: C++
*/

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define PII pair<int,int>
#define inf 1000000001
using namespace std;

map<string,int>m , p;

int n, x[300001], y[300001], l, r;

long long ans;

int main()
{
	
//	ifstream cin("triangles.in");
//	ofstream cout("triangles.out");
	
	cin>>n;
	
	for(int i=1;i<=n;i++){
		
		cin>>x[i]>>y[i];
		
		string s = "", ss = "";
		
		for(int j=31;j>=0;j--){
			
			int k = (1<<j);
			
			if(x[i]&k) s+='1';
			else s+='0';
			
			if(y[i]&k) ss+='1';
			else ss+='0';
		}
		
		
		m[s]++;
		p[ss]++;
		
	}
	
	
	for(int i=1;i<=n;i++){
		
		string s="", ss="";
		
		for(int j=31;j>=0;j--){
			
			int k = (1<<j);
			
			if(x[i]&k) s += '1';
			else s += '0';
			
			if(y[i]&k) ss += '1';
			else ss +='0';
			
		}
		
		l = m[s];
		r = p[ss];
		
		l--;
		r--;
		
		ans += l*r;
		
	}
	
	cout<<ans<<"\n";
	
}

/*
4
0 0
1 0
0 1
1 1
_________oBBBBB8o   oBBBBBBB8
_____o8BBBBBBBBBBB  BBBBBBBBB8        o88o
___o8BBBBBB**8BBBB  BBBBBBBBBB     oBBBBBBBo
__oBBBBBBB*   ***   BBBBBBBBBB     BBBBBBBBBBo
_8BBBBBBBBBBooooo   *BBBBBBB8      *BB* 8BBBBBBo
_8BBBBBBBBBBBBBBBB8ooBBBBBBB8           8BBBBBBB8
__*BBBBBBBBBBBBBBBBBBBBBBBBBB8 o88BB88BBBBBBBBBBBB
____*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8
______**8BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB*
___________*BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB8*
____________*BBBBBBBBBBBBBBBBBBBBBBBB8888**
_____________BBBBBBBBBBBBBBBBBBBBBBB*
_____________*BBBBBBBBBBBBBBBBBBBBB*
______________*BBBBBBBBBBBBBBBBBB8
_______________*BBBBBBBBBBBBBBBB*
________________8BBBBBBBBBBBBBBB8
_________________8BBBBBBBBBBBBBBBo
__________________BBBBBBBBBBBBBBB8
__________________BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBB8
__________________*BBBBBBBBBBBBBBBB
__________________8BBBBBBBBBBBBBBBB8
_________________oBBBBBBBBBBBBBBBBBB
________________oBBBBBBBBBBBBBBBBBBB
________________BBBBBBBBBBBBBBBBBBBB
_______________8BBBBBBBBBBBBBBBBBBB8
______________oBBBBBBBBB88BBBBBBBBB8
______________8BBBBBBBBB*8BBBBBBBBB*
______________BBBBBBBBB* BBBBBBBBB8
______________BBBBBBBB8 oBBBBBBBBB*
______________8BBBBBBB  oBBBBBBBB*
______________BBBBBBB*  8BBBBBBB*
_____________8BBBBBB*   BBBBBBB*
____________8BBBBBB8   oBBBBBB8
___________8BBBBBB8    8BBBBBB*
__________oBBBBBB8    BBBBBBB8
__________BBBBBBB8   BBBBBBBB*
_________oBBBBBBB8   BBBBBBBB
_________8BBBBBB8    BBBBBBB*
_________BBBBBB*     8BBBBB*
________oBBBB8       BBBBB*
________oBBB8        BBBB*
________BBBB8       8BBBBo
_______8BBBB*      oBBBBBBo
______8BBBB*       *BBBBBBBB8o
______BBBBB*            *88BBBo
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 524 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 5 ms 772 KB Output is correct
12 Correct 39 ms 2068 KB Output is correct
13 Correct 41 ms 2340 KB Output is correct
14 Correct 55 ms 3448 KB Output is correct
15 Correct 741 ms 12068 KB Output is correct
16 Correct 689 ms 14576 KB Output is correct
17 Correct 722 ms 16508 KB Output is correct
18 Correct 654 ms 18624 KB Output is correct
19 Execution timed out 2049 ms 26460 KB Time limit exceeded
20 Halted 0 ms 0 KB -