-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj2503.cpp
More file actions
65 lines (59 loc) · 1.42 KB
/
boj2503.cpp
File metadata and controls
65 lines (59 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
using namespace std;
typedef struct query{
int n;
int s;
int b;
}query;
const int MAX = 10e+6;
const int INF = 0x66554433;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
Quick_IO();
int t;
int n, s, b;
int answer = 0;
vector<query> queries;
cin>>t;
function<int(int, int, int, int)> check = [](int num, int num1, int s, int b){
string numString = to_string(num);
string numString1 = to_string(num1);
int temps = 0;
int tempb = 0;
for(int i = 0;i<3;i++){
for(int j = 0;j<3;j++){
if(numString[i]==numString1[j]){
if(i==j) temps++;
else tempb++;
}
}
}
if(tempb==b && temps==s) return 1;
else return 0;
};
while(t--){
cin>>n>>s>>b;
queries.push_back({n, s, b});
}
for(int i = 100;i<1000;i++){
string a = to_string(i);
if(a[0]==a[1] || a[1]==a[2] || a[0]==a[2]||a[0]=='0'||a[1]=='0'||a[2]=='0') continue;
int temp = 0;
for(auto q:queries){
temp += check(i, q.n, q.s, q.b);
}
if(temp == queries.size()) answer++;
}
cout<<answer<<"\n";
return 0;
}