# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
785266 |
2023-07-17T07:45:30 Z |
반딧불(#10021) |
Raspad (COI17_raspad) |
C++17 |
|
529 ms |
42080 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int xx[]={0,1,0,-1},yy[]={1,0,-1,0};
struct unionFind{
int sum;
int par[50002];
void init(int n){
for(int i=1; i<=n; i++) par[i] = i;
sum = 0;
}
int find(int x){
if(x==par[x]) return x;
return par[x] = find(par[x]);
}
void merge(int x, int y){
x = find(x), y = find(y);
if(x==y) return;
par[x] = y;
sum--;
}
} dsu;
int n, m;
int arr[100002][52];
int num[100002][52];
ll ans;
int main(){
scanf("%d %d", &n, &m);
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
scanf("%1d", &arr[i][j]);
num[i][j] = (i-1)*m+j;
}
}
for(int i=1; i<=n; i++){
dsu.init(n*m);
for(int j=i; j<=n; j++){
for(int k=1; k<=m; k++){
if(!arr[j][k]) continue;
dsu.sum++;
for(int d=0; d<4; d++){
int tx = j+xx[d], ty = k+yy[d];
if(tx<1||tx>n||ty<1||ty>m||!arr[tx][ty]||make_pair(j,k)<make_pair(tx,ty)||tx<i) continue;
dsu.merge(num[j][k], num[tx][ty]);
}
}
ans += dsu.sum;
}
}
printf("%lld", ans);
}
Compilation message
raspad.cpp: In function 'int main()':
raspad.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
raspad.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%1d", &arr[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
213 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
529 ms |
904 KB |
Output is correct |
10 |
Correct |
115 ms |
808 KB |
Output is correct |
11 |
Correct |
311 ms |
896 KB |
Output is correct |
12 |
Correct |
71 ms |
752 KB |
Output is correct |
13 |
Correct |
251 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
85 ms |
42080 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
340 KB |
Output is correct |
7 |
Correct |
213 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
529 ms |
904 KB |
Output is correct |
10 |
Correct |
115 ms |
808 KB |
Output is correct |
11 |
Correct |
311 ms |
896 KB |
Output is correct |
12 |
Correct |
71 ms |
752 KB |
Output is correct |
13 |
Correct |
251 ms |
852 KB |
Output is correct |
14 |
Runtime error |
85 ms |
42080 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |