# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219397 |
2020-04-05T08:46:08 Z |
VEGAnn |
Skandi (COCI20_skandi) |
C++14 |
|
7 ms |
768 KB |
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define PB push_back
#define pii pair<int,int>
#define MP make_pair
#define ft first
#define sd second
using namespace std;
const int N = 510;
const int K = 1520;
const int oo = 2e9;
const int md = int(1e9) + 7;
vector<pii> vc;
char c[N][N], cc[N][N];
int n, m, ans = oo, mem;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cin >> c[i][j];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++){
if (c[i][j] == '0') continue;
if (i < n - 1 && c[i + 1][j] == '0')
vc.PB(MP(i * m + j, 0));
if (j < m - 1 && c[i][j + 1] == '0')
vc.PB(MP(i * m + j, 1));
}
for (int msk = 0; msk < (1 << sz(vc)); msk++){
int kol = __builtin_popcount(msk);
if (kol >= ans) continue;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
cc[i][j] = c[i][j];
for (int id = 0; id < sz(vc); id++)
if (msk & (1 << id)){
int x = vc[id].ft / m;
int y = vc[id].ft % m;
if (vc[id].sd){
int yy = y + 1;
while (yy < m && c[x][yy] == '0'){
cc[x][yy] = '1';
yy++;
}
} else {
int xx = x + 1;
while (xx < n && c[xx][y] == '0'){
cc[xx][y] = '1';
xx++;
}
}
}
bool ok = 1;
for (int i = 0; i < n && ok; i++)
for (int j = 0; j < m && ok; j++)
if (cc[i][j] == '0')
ok = 0;
if (ok && ans > kol){
ans = kol;
mem = msk;
}
}
cout << ans << '\n';
for (int it = 0; it < sz(vc); it++)
if (mem & (1 << it)){
int x = vc[it].ft / m;
int y = vc[it].ft % m;
cout << x + 1 << " " << y + 1 << " " << ((vc[it].sd == 0) ? "DOLJE\n" : "DESNO\n");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct. |
2 |
Correct |
5 ms |
384 KB |
Correct. |
3 |
Correct |
5 ms |
384 KB |
Correct. |
4 |
Correct |
6 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
5 ms |
384 KB |
Correct. |
7 |
Correct |
5 ms |
384 KB |
Correct. |
8 |
Correct |
5 ms |
384 KB |
Correct. |
9 |
Correct |
4 ms |
384 KB |
Correct. |
10 |
Correct |
5 ms |
384 KB |
Correct. |
11 |
Correct |
5 ms |
384 KB |
Correct. |
12 |
Correct |
6 ms |
384 KB |
Correct. |
13 |
Correct |
5 ms |
384 KB |
Correct. |
14 |
Correct |
5 ms |
384 KB |
Correct. |
15 |
Correct |
5 ms |
384 KB |
Correct. |
16 |
Correct |
4 ms |
384 KB |
Correct. |
17 |
Correct |
5 ms |
384 KB |
Correct. |
18 |
Correct |
5 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
5 ms |
384 KB |
Correct. |
21 |
Correct |
5 ms |
384 KB |
Correct. |
22 |
Correct |
5 ms |
384 KB |
Correct. |
23 |
Correct |
5 ms |
384 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
768 KB |
First line is not correct. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct. |
2 |
Correct |
5 ms |
384 KB |
Correct. |
3 |
Correct |
5 ms |
384 KB |
Correct. |
4 |
Correct |
6 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
5 ms |
384 KB |
Correct. |
7 |
Correct |
5 ms |
384 KB |
Correct. |
8 |
Correct |
5 ms |
384 KB |
Correct. |
9 |
Correct |
4 ms |
384 KB |
Correct. |
10 |
Correct |
5 ms |
384 KB |
Correct. |
11 |
Correct |
5 ms |
384 KB |
Correct. |
12 |
Correct |
6 ms |
384 KB |
Correct. |
13 |
Correct |
5 ms |
384 KB |
Correct. |
14 |
Correct |
5 ms |
384 KB |
Correct. |
15 |
Correct |
5 ms |
384 KB |
Correct. |
16 |
Correct |
4 ms |
384 KB |
Correct. |
17 |
Correct |
5 ms |
384 KB |
Correct. |
18 |
Correct |
5 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
5 ms |
384 KB |
Correct. |
21 |
Correct |
5 ms |
384 KB |
Correct. |
22 |
Correct |
5 ms |
384 KB |
Correct. |
23 |
Correct |
5 ms |
384 KB |
Correct. |
24 |
Incorrect |
7 ms |
768 KB |
First line is not correct. |
25 |
Halted |
0 ms |
0 KB |
- |