Submission #244195

# Submission time Handle Problem Language Result Execution time Memory
244195 2020-07-02T18:41:52 Z MatesV13 Raspad (COI17_raspad) C++11
9 / 100
6000 ms 768 KB
#include <bits/stdc++.h>
using namespace std;
long long n, m, v[1005][55], ans; char c;
/*int par[1005][55];
inline int kompinx(int a1, int a2, int b1, int b2){
	if (par[a1][a2]==a1*m+a2) return par[a1][a2];
	par[b1][b2] = kompinx((par[a1][a2]-1)/m+1, (par[a1][a2]-1)%m+1, b1, b2);
}*/
bool bio[1005][55];
void dfs(int x, int y){
	bio[x][y]=0;
	if (bio[x+1][y]) dfs(x+1, y);
	if (bio[x-1][y]) dfs(x-1, y);
	if (bio[x][y+1]) dfs(x, y+1);
	if (bio[x][y-1]) dfs(x, y-1);
}
long long ufind (int l, int r){
	int sol=0;
	for (int i=l; i<=r; i++)
		for (int j=1; j<=m; j++)
			bio[i][j]=v[i][j];
	for (int i=l; i<=r; i++)
		for (int j=1; j<=m; j++)
			if (bio[i][j]){
				sol++;
				dfs(i, j);
			}
	return sol;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i=1; i<=n; i++){
	for (int j=1; j<=m; j++){
		cin >> c;
		v[i][j] = c-'0';
	}
}
for (int l=1; l<=n; l++){
	for (int r=l; r<=n; r++){
		ans+=ufind(l, r); //ans+=cur;
	}
} cout << ans << endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 75 ms 384 KB Output is correct
3 Correct 44 ms 512 KB Output is correct
4 Correct 59 ms 544 KB Output is correct
5 Correct 49 ms 384 KB Output is correct
6 Correct 59 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 75 ms 384 KB Output is correct
3 Correct 44 ms 512 KB Output is correct
4 Correct 59 ms 544 KB Output is correct
5 Correct 49 ms 384 KB Output is correct
6 Correct 59 ms 384 KB Output is correct
7 Execution timed out 6023 ms 768 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 75 ms 384 KB Output is correct
3 Correct 44 ms 512 KB Output is correct
4 Correct 59 ms 544 KB Output is correct
5 Correct 49 ms 384 KB Output is correct
6 Correct 59 ms 384 KB Output is correct
7 Execution timed out 6023 ms 768 KB Time limit exceeded
8 Halted 0 ms 0 KB -