QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#714740#5682. PSETzeyu#AC ✓2ms3828kbC++233.0kb2024-11-06 04:22:282024-11-06 04:22:29

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 04:22:29]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3828kb
  • [2024-11-06 04:22:28]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

struct card{
	int a[4];
};

#define pc pair<card, card>

bool isset(vector<card> v){
	bool ok = true;
	for (int i = 0; i < 4; i ++){
		bool allsame = true, alldiff = true;
		for (int j = 0; j < 3; j ++){
			for (int k = j + 1; k < 3; k ++){
				if (v[j].a[i] != v[k].a[i]) allsame = false;
				else alldiff = false;
			}
		}
		if (! allsame && ! alldiff) ok = false;
	}
	return ok;
}

bool good(vector<pc> v){
	for (int i = 0; i < (1 << 3); i ++){
		vector<card> v1, v2;
		for (int j = 0; j < 3; j ++){
			if ((i >> j) & 1){
				v1.push_back(v[j].fi);
				v2.push_back(v[j].se);
			} else{
				v1.push_back(v[j].se);
				v2.push_back(v[j].fi);
			}
		}
		if (isset(v1) && isset(v2)) return true;
	}
	return false;
}
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	map<char, int> mp;
	mp['1'] = 0; mp['2'] = 1; mp['3'] = 2;
	mp['A'] = 0; mp['D'] = 1; mp['O'] = 2;
	mp['E'] = 0; mp['S'] = 1; mp['F'] = 2;
	mp['R'] = 0; mp['G'] = 1; mp['B'] = 2;
	vector<pc> a;
	for (int i = 0; i < n; i ++){
		card c1, c2;
		string s1, s2; cin >> s1 >> s2;
		for (int i = 0; i < 4; i ++){
			c1.a[i] = mp[s1[i]];
			c2.a[i] = mp[s2[i]];
		}
		a.push_back({c1, c2});
	}
	int ans = 0;
	for (int i = 0; i < n; i ++){
		for (int j = i + 1; j < n; j ++){
			for (int k = j + 1; k < n; k ++){
				vector<pc> v = {a[i], a[j], a[k]};
				if (good(v)){
					ans ++;
				}
			}
		}
	}
	cout << ans << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

4
3BFD 1RED
1GSA 3GSO
3REA 1BFO
2REO 2BFA

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

7
3GED 1GFD
2RSD 2BSD
1BFA 3REO
2RED 2BFD
3GSD 1GSD
3BFO 1REA
2GEA 2GFO

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

20
1BFD 3RED
1GEO 3GFA
2BEO 2RFA
3RSD 1BSD
1GSO 3GSA
2GFO 2GEA
2BSO 2RSA
2GEO 2GFA
1BFO 3REA
2RED 2BFD
1RFA 3BEO
2BFO 2REA
3BSD 1RSD
3REO 1BFA
1GSD 3GSD
3BSO 1RSA
3BFO 1REA
3RFO 1BEA
1BSA 3RSO
3RFD 1BED

output:

56

result:

ok single line: '56'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

13
2BFO 2REA
3GEO 1GFA
3GFA 1GEO
2BEO 2RFA
1GSA 3GSO
3BFD 1RED
2RFD 2BED
1GEA 3GFO
3BFA 1REO
2RED 2BFD
1BFO 3REA
1RSO 3BSA
1BED 3RFD

output:

16

result:

ok single line: '16'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

17
3RED 1BFD
1RSD 3BSD
1GFD 3GED
2RFA 2BEO
3GFO 1GEA
3RFD 1BED
2BSO 2RSA
2REA 2BFO
3RSA 1BSO
3BEA 1RFO
2BFD 2RED
1BEO 3RFA
2GFO 2GEA
3GSD 1GSD
1RFD 3BED
1REO 3BFA
2GED 2GFD

output:

37

result:

ok single line: '37'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

14
3BSO 1RSA
3GED 1GFD
1REO 3BFA
3RED 1BFD
1RSO 3BSA
1RFO 3BEA
1RFA 3BEO
3RSO 1BSA
3GEO 1GFA
3BFD 1RED
2GFO 2GEA
2RSA 2BSO
3GFA 1GEO
2BED 2RFD

output:

21

result:

ok single line: '21'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

17
3RSO 1BSA
3BED 1RFD
3RSA 1BSO
1RSO 3BSA
3GED 1GFD
3BEO 1RFA
2BFA 2REO
1RFO 3BEA
3BFD 1RED
1RSD 3BSD
1GFO 3GEA
2REA 2BFO
3BFA 1REO
1REA 3BFO
1BFA 3REO
2RSA 2BSO
2GEO 2GFA

output:

34

result:

ok single line: '34'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

6
3BFD 1RED
2GEO 2GFA
1REO 3BFA
2GFO 2GEA
1RSD 3BSD
2BFA 2REO

output:

1

result:

ok single line: '1'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

16
1RSA 3BSO
1GFO 3GEA
2GFA 2GEO
3BFA 1REO
2GSO 2GSA
1BFD 3RED
3GSO 1GSA
2RSO 2BSA
1BEO 3RFA
3GSD 1GSD
3BED 1RFD
3REA 1BFO
1GEO 3GFA
2RSA 2BSO
1GFA 3GEO
1RED 3BFD

output:

28

result:

ok single line: '28'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

6
2BSO 2RSA
2GFO 2GEA
3RFA 1BEO
1BFA 3REO
1GEA 3GFO
2GFD 2GED

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

4
3GSD 1GSD
3BFD 1RED
2BSA 2RSO
2RSD 2BSD

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

6
3GEO 1GFA
3RFD 1BED
2GFA 2GEO
1GFD 3GED
3BSD 1RSD
2GFD 2GED

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

4
3GFA 1GEO
2GSO 2GSA
3GED 1GFD
1BED 3RFD

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

11
3RFO 1BEA
3BSD 1RSD
3GFD 1GED
2GFA 2GEO
3RSD 1BSD
3GSD 1GSD
2REO 2BFA
1GFO 3GEA
1RFD 3BED
1BFA 3REO
3BSA 1RSO

output:

10

result:

ok single line: '10'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3520kb

input:

15
2BED 2RFD
3BEA 1RFO
3GFO 1GEA
3GSA 1GSO
3GEA 1GFO
2RFA 2BEO
1BFO 3REA
3BFO 1REA
1RFD 3BED
3GSD 1GSD
1BFA 3REO
1REO 3BFA
1RED 3BFD
2RSD 2BSD
1GED 3GFD

output:

20

result:

ok single line: '20'