# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
456280 |
2021-08-06T10:33:37 Z |
grt |
Skandi (COCI20_skandi) |
C++17 |
|
277 ms |
524292 KB |
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 510;
int n, m;
char t[nax][nax];
int lft[nax][nax], up[nax][nax];
vi V[nax * nax * 2];
bool vis[nax * nax * 2];
int match[nax * nax * 2];
bool aug(int x) {
vis[x] = true;
for(int nbh : V[x]) if(match[nbh] == -1) {
match[x] = nbh;
match[nbh] = x;
return true;
}
for(int nbh : V[x]) if(!vis[nbh]) {
if(aug(match[nbh])) {
match[x] = nbh;
match[nbh] = x;
return true;
}
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
cin >> t[i][j];
if(t[i][j] == '1') {
lft[i][j] = i * m + j;
up[i][j] = i * m + j;
} else {
lft[i][j] = lft[i][j - 1];
up[i][j] = up[i - 1][j];
V[up[i][j]].PB(lft[i][j] + n * m);
V[lft[i][j] + n * m].PB(up[i][j]);
}
}
}
for(int i = 0; i < n * m * 2; ++i) match[i] = -1;
while(true) {
for(int i = 0; i < n * m * 2; ++i) vis[i] = false;
bool any = false;
for(int i = 0; i < n * m * 2; ++i) {
if(!vis[i] && match[i] == -1 && aug(i)) any = true;
}
if(any) break;
}
int ans = 0;
for(int i = 0; i < n * m; ++i) {
ans += match[i] != -1;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
275 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
9 ms |
14540 KB |
First line is correct, but the reconstruction is not properly formatted. |
2 |
Runtime error |
277 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
275 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |