# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234158 | 2020-05-23T12:26:57 Z | doowey | Skandi (COCI20_skandi) | C++14 | 72 ms | 15460 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N = 510; const int MAX = N * N; char cf[N][N]; int li[N][N]; int up[N][N]; pii did[MAX]; pii rid[MAX]; int use[MAX]; int match[MAX]; bool vis[MAX]; int dis[MAX]; int sa[MAX], sb[MAX]; bool tl[MAX], tr[MAX]; vector<pii> edg; bool chk[MAX]; vector<pii> T[MAX]; int ln, rn; bool dfs(int u){ vis[u]=true; for(auto x : T[u]){ if(match[x.fi] == -1 || (!vis[match[x.fi]] && dis[match[x.fi]] == dis[u] + 1 && dfs(match[x.fi]))){ match[x.fi]=u; use[u]=x.se; return true; } } return false; } void karp(){ int cur = 0, f = 0; for(int i = 1 ; i <= ln; i ++ ){ use[i]=-1; } for(int i = 1; i <= rn; i ++ ){ match[i]=-1; } bool ok = true; while(1){ f = 0; queue<int> bf; for(int i = 1; i <= ln; i ++ ){ if(use[i] == -1){ bf.push(i); dis[i]=0; } else{ dis[i]=-1; } } int node; while(!bf.empty()){ node=bf.front(); bf.pop(); for(auto x : T[node]){ if(match[x.fi] != -1 && dis[match[x.fi]] == -1){ dis[match[x.fi]] = dis[node] + 1; bf.push(match[x.fi]); } } } for(int i = 1; i <= ln; i ++ ) vis[i]=false; for(int i = 1; i <= ln ;i ++ ){ if(use[i] == -1){ f += dfs(i); } } if(!f){ return; } cur += f; } } int main(){ fastIO; int n, m; cin >> n >> m; for(int i = 1; i <= n; i ++ ){ for(int j = 1; j <= m ; j ++ ){ cin >> cf[i][j]; } } bool has; for(int i = 1; i <= n; i ++ ){ has=false; for(int j = 1; j <= m ; j ++ ){ if(cf[i][j] == '0'){ if(!has){ ln++; rid[ln]=mp(i,j); has=true; } li[i][j]=ln; } else{ has=false; } } } for(int i = 1; i <= m ; i ++ ){ has=false; for(int j = 1; j <= n ; j ++ ){ if(cf[j][i] == '0'){ if(!has){ rn++; did[rn]=mp(j,i); has=true; } up[j][i]=rn; } else{ has=false; } } } for(int i = 1; i <= n; i ++ ){ for(int j = 1; j <= m ; j ++ ){ if(cf[i][j]=='1') continue; T[li[i][j]].push_back(mp(up[i][j], (int)edg.size())); edg.push_back(mp(li[i][j],up[i][j])); } } karp(); for(int i = 1; i <= ln; i ++) { if(use[i] != -1){ chk[use[i]]=true; } } for(int i = 0 ; i < edg.size(); i ++ ){ if(chk[i]) continue; if(use[edg[i].fi] == -1) tr[edg[i].se] =true ; if(match[edg[i].se] == -1) tl[edg[i].fi] =true ; } int sol = 0; for(int i = 0 ; i < edg.size(); i ++ ){ if(chk[i]){ sol ++ ; if(tl[edg[i].fi] || tr[edg[i].se]) continue; else tl[edg[i].fi]=true; } } cout << sol << "\n"; for(int i = 1; i <= ln; i ++ ){ if(tl[i]){ cout << rid[i].fi << " " << rid[i].se - 1 << " DESNO\n"; } } for(int i = 1; i <= rn ; i ++ ){ if(tr[i]){ cout << did[i].fi - 1 << " " << did[i].se << " DOLJE\n"; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6528 KB | Correct. |
2 | Correct | 8 ms | 6528 KB | Correct. |
3 | Correct | 8 ms | 6528 KB | Correct. |
4 | Correct | 8 ms | 6528 KB | Correct. |
5 | Correct | 9 ms | 6524 KB | Correct. |
6 | Correct | 8 ms | 6528 KB | Correct. |
7 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
8 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
9 | Correct | 8 ms | 6528 KB | Correct. |
10 | Correct | 8 ms | 6656 KB | Correct. |
11 | Correct | 9 ms | 6528 KB | Correct. |
12 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
13 | Correct | 8 ms | 6528 KB | Correct. |
14 | Correct | 8 ms | 6528 KB | Correct. |
15 | Correct | 8 ms | 6528 KB | Correct. |
16 | Correct | 8 ms | 6528 KB | Correct. |
17 | Correct | 8 ms | 6528 KB | Correct. |
18 | Correct | 8 ms | 6528 KB | Correct. |
19 | Correct | 8 ms | 6528 KB | Correct. |
20 | Correct | 8 ms | 6528 KB | Correct. |
21 | Correct | 9 ms | 6528 KB | Correct. |
22 | Correct | 8 ms | 6528 KB | Correct. |
23 | Correct | 8 ms | 6528 KB | Correct. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 7808 KB | Correct. |
2 | Partially correct | 8 ms | 7424 KB | First line is correct, but the reconstruction is not. |
3 | Partially correct | 9 ms | 8192 KB | First line is correct, but the reconstruction is not. |
4 | Partially correct | 9 ms | 7296 KB | First line is correct, but the reconstruction is not. |
5 | Partially correct | 9 ms | 7296 KB | First line is correct, but the reconstruction is not. |
6 | Partially correct | 8 ms | 6912 KB | First line is correct, but the reconstruction is not. |
7 | Partially correct | 8 ms | 6912 KB | First line is correct, but the reconstruction is not. |
8 | Partially correct | 8 ms | 7296 KB | First line is correct, but the reconstruction is not. |
9 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
10 | Partially correct | 9 ms | 8832 KB | First line is correct, but the reconstruction is not. |
11 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
12 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
13 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
14 | Partially correct | 10 ms | 8904 KB | First line is correct, but the reconstruction is not. |
15 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
16 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
17 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
18 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
19 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
20 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
21 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
22 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
23 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
24 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
25 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
26 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 6528 KB | Correct. |
2 | Correct | 8 ms | 6528 KB | Correct. |
3 | Correct | 8 ms | 6528 KB | Correct. |
4 | Correct | 8 ms | 6528 KB | Correct. |
5 | Correct | 9 ms | 6524 KB | Correct. |
6 | Correct | 8 ms | 6528 KB | Correct. |
7 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
8 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
9 | Correct | 8 ms | 6528 KB | Correct. |
10 | Correct | 8 ms | 6656 KB | Correct. |
11 | Correct | 9 ms | 6528 KB | Correct. |
12 | Partially correct | 8 ms | 6528 KB | First line is correct, but the reconstruction is not. |
13 | Correct | 8 ms | 6528 KB | Correct. |
14 | Correct | 8 ms | 6528 KB | Correct. |
15 | Correct | 8 ms | 6528 KB | Correct. |
16 | Correct | 8 ms | 6528 KB | Correct. |
17 | Correct | 8 ms | 6528 KB | Correct. |
18 | Correct | 8 ms | 6528 KB | Correct. |
19 | Correct | 8 ms | 6528 KB | Correct. |
20 | Correct | 8 ms | 6528 KB | Correct. |
21 | Correct | 9 ms | 6528 KB | Correct. |
22 | Correct | 8 ms | 6528 KB | Correct. |
23 | Correct | 8 ms | 6528 KB | Correct. |
24 | Correct | 9 ms | 7808 KB | Correct. |
25 | Partially correct | 8 ms | 7424 KB | First line is correct, but the reconstruction is not. |
26 | Partially correct | 9 ms | 8192 KB | First line is correct, but the reconstruction is not. |
27 | Partially correct | 9 ms | 7296 KB | First line is correct, but the reconstruction is not. |
28 | Partially correct | 9 ms | 7296 KB | First line is correct, but the reconstruction is not. |
29 | Partially correct | 8 ms | 6912 KB | First line is correct, but the reconstruction is not. |
30 | Partially correct | 8 ms | 6912 KB | First line is correct, but the reconstruction is not. |
31 | Partially correct | 8 ms | 7296 KB | First line is correct, but the reconstruction is not. |
32 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
33 | Partially correct | 9 ms | 8832 KB | First line is correct, but the reconstruction is not. |
34 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
35 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
36 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
37 | Partially correct | 10 ms | 8904 KB | First line is correct, but the reconstruction is not. |
38 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
39 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
40 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
41 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
42 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
43 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
44 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
45 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
46 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
47 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
48 | Partially correct | 10 ms | 8960 KB | First line is correct, but the reconstruction is not. |
49 | Partially correct | 10 ms | 8832 KB | First line is correct, but the reconstruction is not. |
50 | Partially correct | 36 ms | 13552 KB | First line is correct, but the reconstruction is not. |
51 | Partially correct | 58 ms | 13156 KB | First line is correct, but the reconstruction is not. |
52 | Partially correct | 51 ms | 15076 KB | First line is correct, but the reconstruction is not. |
53 | Partially correct | 36 ms | 13676 KB | First line is correct, but the reconstruction is not. |
54 | Partially correct | 41 ms | 13936 KB | First line is correct, but the reconstruction is not. |
55 | Partially correct | 44 ms | 14700 KB | First line is correct, but the reconstruction is not. |
56 | Partially correct | 39 ms | 14060 KB | First line is correct, but the reconstruction is not. |
57 | Partially correct | 38 ms | 13804 KB | First line is correct, but the reconstruction is not. |
58 | Partially correct | 72 ms | 13284 KB | First line is correct, but the reconstruction is not. |
59 | Partially correct | 38 ms | 13676 KB | First line is correct, but the reconstruction is not. |
60 | Partially correct | 41 ms | 14188 KB | First line is correct, but the reconstruction is not. |
61 | Partially correct | 43 ms | 14312 KB | First line is correct, but the reconstruction is not. |
62 | Partially correct | 41 ms | 14060 KB | First line is correct, but the reconstruction is not. |
63 | Partially correct | 39 ms | 14316 KB | First line is correct, but the reconstruction is not. |
64 | Partially correct | 24 ms | 12912 KB | First line is correct, but the reconstruction is not. |
65 | Partially correct | 39 ms | 14196 KB | First line is correct, but the reconstruction is not. |
66 | Partially correct | 46 ms | 14344 KB | First line is correct, but the reconstruction is not. |
67 | Partially correct | 47 ms | 15080 KB | First line is correct, but the reconstruction is not. |
68 | Partially correct | 45 ms | 14828 KB | First line is correct, but the reconstruction is not. |
69 | Partially correct | 41 ms | 14188 KB | First line is correct, but the reconstruction is not. |
70 | Partially correct | 39 ms | 14056 KB | First line is correct, but the reconstruction is not. |
71 | Partially correct | 52 ms | 15460 KB | First line is correct, but the reconstruction is not. |
72 | Partially correct | 40 ms | 14324 KB | First line is correct, but the reconstruction is not. |
73 | Partially correct | 51 ms | 15336 KB | First line is correct, but the reconstruction is not. |
74 | Partially correct | 49 ms | 15336 KB | First line is correct, but the reconstruction is not. |
75 | Partially correct | 50 ms | 15332 KB | First line is correct, but the reconstruction is not. |