Deep Learning study
백준 17281문제 본문
반응형
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int game[55][10];
int where[4];
int score,inni = 1;
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int N;
cin >> N;
for(int i=1 ;i<=N ;i++)
for(int j=1 ; j<=9 ; j++)
cin >> game[i][j];
vector<int> t(8);
for(int i=2 ; i<=9 ; i++) t[i-2] = i;
int ans = 0;
do{
t.insert(t.begin() + 3, 1);
score = 0,inni = 1;
int out = 0,end = 0;
memset(where,0,sizeof(where));
while(inni<=N){
out = 0;
memset(where,0,sizeof(where));
while(true){
int k = game[inni][t[end]];
if(k==1){
if(where[3]) score++, where[3] = 0;
if(where[2]) where[3] = 1, where[2] = 0;
if(where[1]) where[2] = 1, where[1] = 0;
where[1] = 1;
}
else if(k==2){
if(where[3]) score++, where[3] = 0;
if(where[2]) score++, where[2] = 0;
if(where[1]) where[3] = 1, where[1] = 0;
where[2] = 1;
}
else if(k==3){
for(int j=1; j<=3 ; j++)
if(where[j]) score++ , where[j] = 0;
where[3] = 1;
}
else if(k==4){
for(int m = 1 ; m<=3 ; m++)
if(where[m]) score++, where[m]=0;
score++;
}
else out++;
end = (end+1)%9;
if(out == 3){
inni++;
break;
}
}
}
ans = max(ans, score);
t.erase(t.begin() +3);
}while(next_permutation(t.begin(),t.end()));
cout << ans << endl;
return 0;
}
백준 17282 문제 풀이입니다.
반응형
'백준 문제 코드' 카테고리의 다른 글
백준 17471문제 (0) | 2019.12.07 |
---|---|
백준 16637문제 (0) | 2019.12.05 |
백준 17136문제 (0) | 2019.11.24 |
백준 17070문제(DFS 이용) (0) | 2019.11.21 |
백준 17070문제 (DP이용) (0) | 2019.11.21 |
Comments