| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 153408 | mhy908 | Dango Maker (JOI18_dango_maker) | C++14 | 80 ms | 70928 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define llinf 987654321987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m, x;
char str[3010][3010];
int col[3010][3010][3], re[3010][3010], ans;
vector<int> link[3000010];
int ishere[3000010];
int onenum, twonum;
void dfs(int here, int c)
{
if(ishere[here])return;
ishere[here]=c;
if(c==1)onenum++;
else twonum++;
for(int i=0; i<link[here].size(); i++){
dfs(link[here][i], c==1?2:1);
}
}
int main()
{
scanf("%d%d", &n, &m);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
scanf(" %c", &str[i][j]);
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(str[i][j]=='R'&&str[i][j+1]=='G'&&str[i][j+2]=='W'){
++x;
col[i][j][++re[i][j]]=x;
col[i][j+1][++re[i][j+1]]=x;
col[i][j+2][++re[i][j+2]]=x;
}
if(str[i][j]=='R'&&str[i+1][j]=='G'&&str[i+2][j]=='W'){
++x;
col[i][j][++re[i][j]]=x;
col[i+1][j][++re[i+1][j]]=x;
col[i+2][j][++re[i+2][j]]=x;
}
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(re[i][j]==2){
link[col[i][j][1]].pb(col[i][j][2]);
link[col[i][j][2]].pb(col[i][j][1]);
}
}
}
for(int i=1; i<=x; i++){
if(ishere[i])continue;
onenum=twonum=0;
dfs(i, 1);
ans+=max(onenum, twonum);
}
printf("%d", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
