#40336: WA? #0: 100% WA (line:9) 您的答案為: 0A1B 正確答案為: 1A1B 為啥


Arthooooo (unknown)

學校 : 不指定學校
編號 : 259565
來源 : [140.113.136.213]
最後登入時間 :
2024-10-01 11:45:54
a291. nAnB problem | From: [49.217.199.236] | 發表日期 : 2024-05-11 13:10

//a229
#include <bits/stdc++.h>
 
using namespace std;
void compare(string ansr, string keyr){
int a = 0, b = 0; 
int ans[4], key[4];
vector<int> used;
for(int i = 0 ; i < 7; i+=2){
ans[i/2] = ansr[i] - '0';
key[i/2] = keyr[i] - '0';
if(ans[i/2] == key[i/2]){
a++;
used.push_back(i/2);
ans[i/2] = 10;
key[i/2] = 10;
}
}
for(int i = 0 ; i < 4; i++){
for(int j = 0 ; j < 4; j++){
if(ans[i] != 10 && key[j] != 10){
if(ans[i] == key[j]){
b++;
ans[i] = 10;
key[j] = 10;
}
}
}
}
cout << a << 'A'<< b << 'B' << endl;
 
 
 
 
 
}
void solve(string ans){
string n;
getline(cin, n);
string key;
for(int i = 1; i <= n[0] - '0' ; i++){
getline(cin, key);
compare(ans, key);
}
cin.ignore(numeric_limits<streamsize>::max(), '\n');
 
}
int main(){
string s;
while(getline(cin, s))
solve(s);
}

 

 
ZeroJudge Forum