Submission #935926

# Submission time Handle Problem Language Result Execution time Memory
935926 2024-02-29T18:56:18 Z Litusiano Cards (LMIO19_korteles) C++17
36 / 100
1000 ms 36568 KB
 #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define s second
#define f first
 
 int check1(vector<char> a, vector<char> b){
 	int ans = 0;
	if(a[0] == b[3] && a[1] == b[4]) ans++;
	if(a[0] == b[2] && a[2] == b[4]) ans++;
	if(a[1] == b[1] && a[3] == b[3]) ans++;
	if(a[2] == b[1] && a[3] == b[2]) ans++;
	return ans;
}
 
vector<char> find(vector<char> v){
	vector<char> k(4,' ');
	k[3-1] = v[1]; k[4-1] = v[2];
	k[0] = v[3]; k[2-1] = v[4];
	if(check1(k,v) == 4) return k;
	return {}; 
}
 
signed main(){
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
	int n; cin>>n;
	map<pair<char,char>,int> m12,m13,m34,m24;
	map<vector<char>,int> m1234,m123, m124, m134, m234;
	int ans = 0;
	for(int i = 0; i<n; i++){
 
 
		// 100% CHECKED
 
		vector<char> v(5); cin>>v[1]>>v[2]>>v[3]>>v[4];
		if(m34.find({v[1],v[2]}) != m34.end()){
			ans+= m34[{v[1],v[2]}];
		}
		// if(i+1 == n) cerr<<"ANS: "<<ans<<endl;
		if(m12.find({v[3],v[4]}) != m12.end()){
			ans+= m12[{v[3],v[4]}];
		}
		// if(i+1 == n) cerr<<"ANS: "<<ans<<endl;
		if(m13.find({v[2],v[4]}) != m13.end()){
			ans+= m13[{v[2],v[4]}];
		}
		// if(i+1 == n) cerr<<"ANS: "<<ans<<endl;
		if(m24.find({v[1],v[3]}) != m24.end()){
			ans+= m24[{v[1],v[3]}];
		}
 
 
		// cerr<<"ANS: "<<ans<<" "<<v[1]<<v[2]<<v[3]<<" "<<m234[{v[1],v[2],v[3]}]<<endl;
		if(v[2] == v[3] && m234.find({v[2],v[4]}) != m234.end()){
			ans-=m234[{v[2],v[4]}];
		}
		if(v[2] == v[3]) m234[{v[1],v[3]}]++;
 
 
 
		// if(i+1 == n) cerr<<"ANS: "<<ans<<endl;
		ans+= m1234[find(v)];
		  // cerr<<"HERE ANS: "<<ans<<" "<<m1234[find(v)]<<endl;
		if(v[2] == v[3] && m123.find({v[1],v[2]}) != m123.end()){
			ans-=m123[{v[1],v[2]}];
		}
		// cerr<<"ANS: "<<ans<<" "<<v[1]<<v[3]<<v[4]<<" "<<m124[{v[1],v[3],v[4]}]<<endl;
		if(v[1] == v[4] && m124.find({v[1],v[2]}) != m124.end()){
			ans-=m124[{v[1],v[2]}];
		}
		if(v[1] == v[4] && m134.find({v[1],v[3]}) != m134.end()){
			ans-=m134[{v[1],v[3]}];
		}
		
 		// cerr<<"ANS: "<<ans<<" "<<v[1]<<v[2]<<v[4]<<" "<<m134[{v[1],v[2],v[4]}]<<endl;
 
		vector<char> v1 = {v[2],v[1],v[4],v[3]};
		if(v1 != find(v) && !(v[1] == v[2] && v[3] == v[4] && v[1] == v[3]) && m1234.find(v1) != m1234.end()){
			ans-=m1234[{v[2],v[1],v[4],v[3]}];
		}
		// if((v[1] == v[2] || v[3] == v[4]) && !(v[1] == v[2] && v[3] == v[4])&& m1234.find(v1) != m1234.end()){
		// 	// 3!
		// 	ans+=m1234[v1];
		// }
		vector<char> v2 = {v[3],v[4],v[1],v[2]}; // TAKE CARE OF 2 AND 3
		if(v2 != find(v) && v1 != v2 && !(v[1] == v[3] && v[2] == v[4] && v[1] == v[2]) && m1234.find(v2) != m1234.end()){
			ans-=m1234[v2];
		}
 		// if((v[1] == v[3] || v[2] == v[4]) && !(v[4] == v[2] && v[3] == v[1])&& m1234.find(v1) != m1234.end()){
		// 	// 3!
		// 	ans+=m1234[v1];
		// }
 
 
 
 
		// if(i+1 == n) cerr<<"ANS: "<<ans<<endl;
		m12[{v[1],v[2]}]++;
		m13[{v[1],v[3]}]++;
		m34[{v[3],v[4]}]++;
		m24[{v[2],v[4]}]++;
		m1234[{v[1],v[2],v[3],v[4]}]++;
 
 
 
 
		
		if(v[4] == v [1]) m134[{v[2],v[4]}]++;
 
		
		if(v[1] == v[4]) m124[{v[3],v[4]}]++;
 
		if(v[2] == v[3]) m123[{v[2],v[4]}]++;
 
		
	}
	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 412 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 4 ms 592 KB Output is correct
8 Correct 5 ms 892 KB Output is correct
9 Correct 5 ms 856 KB Output is correct
10 Correct 6 ms 856 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 36568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 110 ms 6240 KB Output is correct
3 Execution timed out 1016 ms 35044 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 5 ms 892 KB Output is correct
5 Correct 5 ms 856 KB Output is correct
6 Correct 6 ms 856 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 412 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Execution timed out 1091 ms 36568 KB Time limit exceeded
13 Halted 0 ms 0 KB -