#include <iostream>
#include <vector>
using namespace std;
int number;
int strike, ball;
vector<int> array;
void Filtering(int num, int s, int b)
{
vector<int> newarray;
vector<int>::iterator iter;
int strike = 0, ball = 0;
for (iter = array.begin(); iter != array.end(); iter++)
{
int strike = 0, ball = 0;
// cout << *iter << "๊ฒ์ฌ\n";
int a1 = num / 100;
int b1 = num / 10 % 10;
int c1 = num % 10;
int a2 = *iter / 100;
int b2 = *iter / 10 % 10;
int c2 = *iter % 10;
// cout << a1 << a2 << "/" << b1 << b2 << "/" << c1 << c2 << "\n";
if (a1 == a2)
strike++;
else if (a1 == b2)
ball++;
else if (a1 == c2)
ball++;
if (b1 == b2)
strike++;
else if (b1 == a2)
ball++;
else if (b1 == c2)
ball++;
if (c1 == c2)
strike++;
else if (c1 == a2)
ball++;
else if (c1 == b2)
ball++;
if (strike == s && ball == b && a2 != b2 && b2 != c2 && a2 != c2 && a2 != 0 && b2 != 0 && c2 != 0)
{
newarray.push_back(*iter);
// cout << *iter << "\n";
}
}
array = newarray;
return;
}
int main()
{
int T;
cin >> T;
for (int i = 123; i <= 987; i++)
{
array.push_back(i);
}
for (int i = 0; i < T; i++)
{
cin >> number >> strike >> ball;
Filtering(number, strike, ball);
// cout << "****************************\n";
}
cout << array.size();
}
์ด์ ๋งจ ์ฒ์์ 123~987 ๋ก array๋ฅผ ์ ๋ฐ์ดํธ ใ ใ ์ฃผ๊ณ , ์ด ์์์ ๊ฐ ์๋ฆฌ ์ซ์๋ฅผ ๊ตฌํด์ strike๋ ball์ ๊ตฌํ ๋ค, ํจ์ ์ธ์๋ก ๋๊ฒจ์ค ์ ๋ต strike, ball๊ณผ ๊ฐ์ด ์ผ์นํ๋์ง ๊ฒ์ฌํจ. ๊ทธ๋์ ์ผ์นํ๋ฉด ๊ทธ ์ซ์๋ ๊ฐ๋ฅํ ์ซ์์ด๋ฏ๋ก newArray์ ์ถ๊ฐํด์ค. ์ด ์ง์ ๋ชจ๋ array์ ์๋ ๊ฐ์ ๋ํด ํด์ค ๋ค, newArray๋ก array๋ฅผ ๋์ฒดํด์ค. (์ ๋ฐ์ดํธ ํด์ฃผ๋๊ฒ!)
์ด ๋, ๊ฐ ์๋ฆฌ ์ซ์์ 0์ด ์๊ฑฐ๋, ๊ฐ์ ์ซ์๊ฐ ์๋ ๊ฒฝ์ฐ๋ ์ถ๊ฐํด ์ฃผ๋ฉด ์๋๋ค.
'๐ก๐ธ๐ธ๐ถ๐ฃ: ๐๐๐๐๐๐พ๐๐ฝ๐ > ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ํ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ5671 : ํธํ ๋ฐฉ ๋ฒํธ (Silver 5) (0) | 2021.08.20 |
---|---|
BOJ14889 : ์คํํธ์ ๋งํฌ (Silver 3) (0) | 2021.08.20 |
BOJ17404 : RGB๊ฑฐ๋ฆฌ2 (Gold 4) (0) | 2021.08.17 |
BOJ1149 : RGB๊ฑฐ๋ฆฌ (Silver 1) (0) | 2021.08.17 |
BOJ11660 : ๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ 5 (Silver 1) (0) | 2021.08.15 |