# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
350123 | 2021-01-19T02:03:47 Z | arnold518 | Raspad (COI17_raspad) | C++14 | 384 ms | 816 KB |
#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); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 4 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Correct | 2 ms | 364 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 4 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Correct | 2 ms | 364 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 153 ms | 748 KB | Output is correct |
8 | Correct | 2 ms | 492 KB | Output is correct |
9 | Correct | 384 ms | 748 KB | Output is correct |
10 | Correct | 93 ms | 768 KB | Output is correct |
11 | Correct | 241 ms | 748 KB | Output is correct |
12 | Correct | 66 ms | 748 KB | Output is correct |
13 | Correct | 196 ms | 816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 620 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 4 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Correct | 2 ms | 364 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 153 ms | 748 KB | Output is correct |
8 | Correct | 2 ms | 492 KB | Output is correct |
9 | Correct | 384 ms | 748 KB | Output is correct |
10 | Correct | 93 ms | 768 KB | Output is correct |
11 | Correct | 241 ms | 748 KB | Output is correct |
12 | Correct | 66 ms | 748 KB | Output is correct |
13 | Correct | 196 ms | 816 KB | Output is correct |
14 | Incorrect | 2 ms | 620 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |