이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
tomorrow will worse
but the day after tomorrow will be the sunshine..
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up */
///* __ __ __ */
///* ====== _ /| /| __ _ / | | /| | @ | | | | / /| |\ | / | | @ | / */
///* \- || |_| |_ / |/ | | | |_ |- | |--| /-| | | \ \ |==| |- /=| | \ | | |--| | |- */
///* || | | |_ / | |__| _| |_ \__ | | / | |__ | __| | | | \ / | | \| \__ | | | | \ */
///* */
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
const long long N = 4e3+50, inf = 1e18, mod = 1e9+7;
int n, m, ans;
int a[N][N];
map<vector<vi>, bool> mp;
void rec(vector<vi> &us, int cnt){
if(mp[us])return;
mp[us]=1;
ans = max(ans, cnt);
for(int i = 0; i < n; i++){
for(int j = 0; j < m - 2; j++){
if(a[i][j] == 1 && a[i][j+1] == 2 && a[i][j+2] == 3 && (!us[i][j] && !us[i][j+1] && !us[i][j+2])){
us[i][j] = 1;us[i][j+1] = 1;us[i][j+2] = 1;
if(!mp[us])rec(us, cnt+1);
us[i][j] = 0;us[i][j+1] = 0;us[i][j+2] = 0;
}
}
}
for(int i = 0; i < n - 2; i++){
for(int j = 0; j < m; j++){
if(a[i][j] == 1 && a[i+1][j] == 2 && a[i+2][j] == 3 && (!us[i][j] && !us[i+1][j] && !us[i+2][j])){
us[i][j] = 1;us[i+1][j] = 1;us[i+2][j] = 1;
if(!mp[us])rec(us, cnt+1);
us[i][j] = 0;us[i+1][j] = 0;us[i+2][j] = 0;
}
}
}
}
void solve(){
cin >> n >> m;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char x;
cin >> x;
if(x=='R')a[i][j] = 1;
else if(x=='G')a[i][j] = 2;
else a[i][j] = 3;
}
}
vector<vector<int>> us(n, vector<int> (m));
rec(us, 0);
cout << ans << '\n';
}
main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t = 1;
//~ cin >> t;
while(t--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
dango_maker.cpp:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
66 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |