QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618715 | #7813. 密码锁 | crazy_monkey | 30 | 1ms | 3696kb | C++14 | 2.0kb | 2024-10-07 08:44:22 | 2024-10-07 08:44:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=10;
int a[N][5];
int n,ans=0,ans1=0,ans2=0;
int s[5];
void quan(int id){
if(id==5){
int flg=0,dif;
for(int k=0;k<n;k++){
dif=0;
for(int j=0;j<5;j++){
if(s[j]!=a[k][j]){
dif++;
}
}
if(dif>=3||dif==0){
flg=0;
break;
}
else if(dif==1){
flg=1;
ans1++;
}
else if(dif==2){
int flg2=0;
for(int j=0;j<4;j++){
if(s[j]!=a[k][j]&&s[j+1]!=a[k][j+1]){
if(a[k][j]==a[k][j+1]&&s[j]==s[j+1]){
flg=1;
flg2=1;
break;
}
else if(a[k][j]==a[k][j+1]&&s[j]!=s[j+1]){
flg2=0;
break;
}
if(s[j]<a[k][j]&&s[j+1]>a[k][j+1]){
if(s[j]-a[k][j]==s[j+1]-a[k][j+1]){
flg=1;
flg2=1;
break;
}
}
else if(s[j]<a[k][j]&&s[j+1]<a[k][j+1]){
if(a[k][j]-s[j]==a[k][j+1]-s[j+1]){
flg=1;
flg2=1;
break;
}
}
else if(s[j]>a[k][j]&&s[j+1]>a[k][j+1]){
if(abs(a[k][j]-s[j])==abs(a[k][j+1]-s[j+1])){
flg=1;
flg2=1;
break;
}
}
else if(s[j]>a[k][j]&&s[j+1]<a[k][j+1]){
if(abs(a[k][j]-s[j])==a[k][j+1]-s[j+1]){
flg=1;
flg2=1;
break;
}
}
// if(s[j]-a[k][j]==s[j+1]-a[k][j+1]){
// flg=1;
// ans2++;
// break;
// }
}
}
if(!flg2){
flg=0;
break;
}
}
}
ans+=flg;
if(dif==2) ans2+=flg;
// if(flg){
// cout << "第" << ans << "个";
// for(int i=0;i<5;i++){
// cout << s[i];
// }
// cout << endl;
// }
return;
}
for(int i=0;i<=9;i++){
s[id]=i;
quan(id+1);
s[id]=-1;
}
}
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3] >> a[i][4];
}
if(n==1){
cout << 81;
return 0;
}
quan(0);
cout << ans;
cout << endl << ans1 << " " << ans2;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 0ms
memory: 3536kb
input:
1 4 9 8 2 5
output:
81
result:
ok single line: '81'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3608kb
input:
1 7 7 5 2 0
output:
81
result:
ok single line: '81'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3628kb
input:
1 8 9 8 7 8
output:
81
result:
ok single line: '81'
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
2 0 3 7 3 8 0 3 6 7 8
output:
6 48 3
result:
wrong output format Extra information in the output file
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 3692kb
input:
2 7 3 7 9 7 3 3 7 9 3
output:
2 47 0
result:
wrong output format Extra information in the output file
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
4 8 6 9 9 4 8 6 8 9 4 8 6 7 9 4 8 6 1 9 4
output:
6 69 0
result:
wrong output format Extra information in the output file
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 3564kb
input:
6 0 8 3 9 0 0 4 3 9 0 0 0 3 9 0 0 3 3 9 0 0 5 3 9 0 0 6 3 9 0
output:
4 76 0
result:
wrong output format Extra information in the output file
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3688kb
input:
7 2 2 5 6 3 1 8 5 6 3 2 8 7 6 3 2 8 6 6 3 2 8 8 6 3 2 1 5 6 3 2 8 9 6 3
output:
1 54 0
result:
wrong output format Extra information in the output file
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 3544kb
input:
5 6 6 6 9 5 6 0 0 9 5 6 1 1 9 5 6 2 2 9 5 6 4 4 9 5
output:
5 47 5
result:
wrong output format Extra information in the output file
Test #10:
score: 0
Wrong Answer
time: 1ms
memory: 3696kb
input:
8 9 0 8 6 0 9 5 2 6 0 9 0 7 0 4 9 0 9 6 0 3 0 7 6 0 9 0 7 6 7 4 0 7 6 0 9 8 7 6 0
output:
0 49 0
result:
wrong answer 1st lines differ - expected: '1', found: '0'