# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219414 |
2020-04-05T09:35:10 Z |
Vimmer |
Skandi (COCI20_skandi) |
C++14 |
|
10000 ms |
384 KB |
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 75005
#define M ll(1e9 + 7)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m;
cin >> n >> m;
string s[n];
for (int i = 0; i < n; i++) cin >> s[i];
vector <pair <int, int> > g; g.clear();
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (s[i][j] == '1' && ((i + 1 != n && s[i + 1][j] == '0') || (j + 1 != m && s[i][j + 1] == '0'))) g.pb({i, j});
int ans = 1e9;
vector <pair <pair <int, int>, int> > gr; gr.clear();
for (int umsk = 0; umsk < (1 << sz(g)); umsk++)
{
if (__builtin_popcount(umsk) >= ans) continue;
vector <int> pr; pr.clear();
for (int i = 0; i < sz(g); i++) if ((1 << i) & umsk) pr.pb(i);
for (int msk = 0; msk < (1 << sz(pr)); msk++)
{
bool gd = 1;
bool mk[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) mk[i][j] = s[i][j] - '0';
for (int i = 0; i < sz(pr); i++)
if ((1 << i) & msk)
{
int x = g[pr[i]].F, y = g[pr[i]].S;
if (y + 1 == m || s[x][y + 1] == '1') {gd = 0; break;}
int j = y + 1;
while (j < m && s[x][j] == '0') {mk[x][j] = 1; j++;}
}
else
{
int x = g[pr[i]].F, y = g[pr[i]].S;
if (x + 1 == n || s[x + 1][y] == '1') {gd = 0; break;}
int j = x + 1;
while (j < n && s[j][y] == '0') {mk[j][y] = 1; j++;}
}
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) if (!mk[i][j]) gd = 0;
if (gd)
{
ans = sz(pr);
gr.clear();
for (int i = 0; i < sz(pr); i++) gr.pb({{g[pr[i]].F, g[pr[i]].S}, (1 << i) & msk});
break;
}
}
}
cout << sz(gr) << endl;
for (auto it : gr) cout << it.F.F + 1 << " " << it.F.S + 1 << " " << (it.S != 0 ? "DESNO" : "DOLJE") << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Correct. |
2 |
Correct |
4 ms |
384 KB |
Correct. |
3 |
Correct |
4 ms |
384 KB |
Correct. |
4 |
Correct |
4 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
4 ms |
384 KB |
Correct. |
7 |
Correct |
5 ms |
384 KB |
Correct. |
8 |
Correct |
5 ms |
384 KB |
Correct. |
9 |
Correct |
5 ms |
384 KB |
Correct. |
10 |
Correct |
5 ms |
384 KB |
Correct. |
11 |
Correct |
4 ms |
384 KB |
Correct. |
12 |
Correct |
4 ms |
384 KB |
Correct. |
13 |
Correct |
5 ms |
384 KB |
Correct. |
14 |
Correct |
4 ms |
384 KB |
Correct. |
15 |
Correct |
5 ms |
384 KB |
Correct. |
16 |
Correct |
4 ms |
384 KB |
Correct. |
17 |
Correct |
4 ms |
384 KB |
Correct. |
18 |
Correct |
4 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
5 ms |
384 KB |
Correct. |
21 |
Correct |
4 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 |
Execution timed out |
10049 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Correct. |
2 |
Correct |
4 ms |
384 KB |
Correct. |
3 |
Correct |
4 ms |
384 KB |
Correct. |
4 |
Correct |
4 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
4 ms |
384 KB |
Correct. |
7 |
Correct |
5 ms |
384 KB |
Correct. |
8 |
Correct |
5 ms |
384 KB |
Correct. |
9 |
Correct |
5 ms |
384 KB |
Correct. |
10 |
Correct |
5 ms |
384 KB |
Correct. |
11 |
Correct |
4 ms |
384 KB |
Correct. |
12 |
Correct |
4 ms |
384 KB |
Correct. |
13 |
Correct |
5 ms |
384 KB |
Correct. |
14 |
Correct |
4 ms |
384 KB |
Correct. |
15 |
Correct |
5 ms |
384 KB |
Correct. |
16 |
Correct |
4 ms |
384 KB |
Correct. |
17 |
Correct |
4 ms |
384 KB |
Correct. |
18 |
Correct |
4 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
5 ms |
384 KB |
Correct. |
21 |
Correct |
4 ms |
384 KB |
Correct. |
22 |
Correct |
5 ms |
384 KB |
Correct. |
23 |
Correct |
5 ms |
384 KB |
Correct. |
24 |
Execution timed out |
10049 ms |
384 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |