# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153400 | mhy908 | Dango Maker (JOI18_dango_maker) | C++14 | 78 ms | 71032 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];
int par[3000010], num[3000010], ans;
vector<int> link[3000010];
int findpar(int num)
{
if(num==par[num])return num;
return par[num]=findpar(par[num]);
}
void mergepar(int a, int b)
{
a=findpar(a);
b=findpar(b);
par[a]=par[b];
}
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<=x; i++)par[i]=i;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
if(re[i][j]==2){
mergepar(col[i][j][1], col[i][j][2]);
}
if(re[i][j]>=3){
int p;
while(1){
p++;
}
}
}
}
for(int i=1; i<=x; i++){
int temp=findpar(i);
num[temp]++;
}
for(int i=1; i<=x; i++){
ans+=(num[i]+1)/2;
}
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... |