# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
350123 | arnold518 | Raspad (COI17_raspad) | C++14 | 384 ms | 816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1000;
const int MAXM = 50;
int N, M;
int A[MAXN+10][MAXM+10];
struct UF
{
int par[MAXN*MAXM+10];
int Find(int x)
{
if(x==par[x]) return x;
return par[x]=Find(par[x]);
}
bool Union(int x, int y)
{
x=Find(x); y=Find(y);
if(x==y) return 0;
par[x]=y;
return 1;
}
}uf;
int f(int y, int x)
{
return (y-1)*M+(x-1);
}
ll ans=0;
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) scanf("%1d", &A[i][j]);
for(int i=1; i<=N; i++)
{
int val=0;
for(int j=i; j<=N; j++)
{
for(int k=1; k<=M; k++)
{
uf.par[f(j, k)]=f(j, k);
}
for(int k=1; k<=M; k++)
{
if(!A[j][k]) continue;
val++;
if(j!=i && A[j-1][k]) val-=uf.Union(f(j, k), f(j-1, k));
if(A[j][k-1]) val-=uf.Union(f(j, k), f(j, k-1));
}
//printf("%d %d : %d\n", i, j, val);
ans+=val;
}
}
printf("%lld\n", 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |