# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219410 |
2020-04-05T09:29:45 Z |
kartel |
Skandi (COCI20_skandi) |
C++14 |
|
10000 ms |
768 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +400500
//#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
int n, m, i, j, k, mask, I, mrk[N];
char c[501][501], c1[501][501];
vector <pair <int, pair <int, int> > > ans;
vector <pair <int, int> > v;
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("qual.in");
// out("qual.out");
cin >> n >> m;
for (i = 1; i <= n; i++)
for (j = 1; j <= m; j++)
{
cin >> c[i][j];
if (c[i][j] == '1') v.pb({i, j}), ans.pb({i, {j + 1, 1}});
}
k = v.size();
for (mask = 0; mask < (1 << k); mask++)
{
for (i = 1; i <= n; i++)
for (j = 1; j <= m; j++) c1[i][j] = c[i][j];
for (i = 0; i < k; i++)
if (mask & (1 << i))
{
I = v[i].F;
j = v[i].S + 1;
while (j <= m && c1[I][j] == '0') c1[I][j]++, j++;
}
else
{
I = v[i].F + 1;
j = v[i].S;
while (I <= n && c1[I][j] == '0') c1[I][j]++, I++;
}
int kol = 0;
for (i = 1; i <= n; i++)
for (j = 1; j <= m; j++) kol += min(1, (c1[i][j] - '0'));
if (kol == n * m)
{
int kl = k;
for (i = 0; i < k; i++) mrk[i] = 0;
for (i = 0; i < k; i++)
if (mask & (1 << i))
{
I = v[i].F;
j = v[i].S + 1;
while (j <= m && c1[I][j] > '1' && c[I][j] == '0') j++;
if (j > m || c[I][j] == '1')
{
kl--;
mrk[i] = 1;
I = v[i].F;
j = v[i].S + 1;
while (j <= m && c1[I][j] > '1' && c[I][j] == '0') c1[I][j]--, j++;
}
}
else
{
I = v[i].F + 1;
j = v[i].S;
while (I <= n && c1[I][j] > '1' && c[I][j] == '0') I++;
if (I > n || c[I][j] == '1')
{
kl--;
mrk[i] = 1;
I = v[i].F + 1;
j = v[i].S;
while (I <= n && c1[I][j] > '1' && c[I][j] == '0') c1[I][j]--, I++;
}
}
if (kl < ans.size())
{
ans.clear();
for (i = 0; i < k; i++)
if (!mrk[i])
{
if (mask & (1 << i))
ans.pb({v[i].F, {v[i].S, 1}});
else ans.pb({v[i].F, {v[i].S, 0}});
}
}
}
}
cout << ans.size() << el;
for (auto it : ans) cout << it.F << " " << it.S.F << " " << ((it.S.S == 1) ? "DESNO" : "DOLJE") << el;
}
Compilation message
skandi.cpp: In function 'int main()':
skandi.cpp:100:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (kl < ans.size())
~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct. |
2 |
Correct |
4 ms |
384 KB |
Correct. |
3 |
Correct |
5 ms |
384 KB |
Correct. |
4 |
Correct |
5 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
5 ms |
384 KB |
Correct. |
7 |
Correct |
4 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 |
4 ms |
384 KB |
Correct. |
12 |
Correct |
5 ms |
384 KB |
Correct. |
13 |
Correct |
4 ms |
384 KB |
Correct. |
14 |
Correct |
4 ms |
384 KB |
Correct. |
15 |
Correct |
4 ms |
384 KB |
Correct. |
16 |
Correct |
5 ms |
384 KB |
Correct. |
17 |
Correct |
5 ms |
384 KB |
Correct. |
18 |
Correct |
4 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
4 ms |
384 KB |
Correct. |
21 |
Correct |
4 ms |
384 KB |
Correct. |
22 |
Correct |
5 ms |
384 KB |
Correct. |
23 |
Correct |
4 ms |
384 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10032 ms |
768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Correct. |
2 |
Correct |
4 ms |
384 KB |
Correct. |
3 |
Correct |
5 ms |
384 KB |
Correct. |
4 |
Correct |
5 ms |
384 KB |
Correct. |
5 |
Correct |
5 ms |
384 KB |
Correct. |
6 |
Correct |
5 ms |
384 KB |
Correct. |
7 |
Correct |
4 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 |
4 ms |
384 KB |
Correct. |
12 |
Correct |
5 ms |
384 KB |
Correct. |
13 |
Correct |
4 ms |
384 KB |
Correct. |
14 |
Correct |
4 ms |
384 KB |
Correct. |
15 |
Correct |
4 ms |
384 KB |
Correct. |
16 |
Correct |
5 ms |
384 KB |
Correct. |
17 |
Correct |
5 ms |
384 KB |
Correct. |
18 |
Correct |
4 ms |
384 KB |
Correct. |
19 |
Correct |
5 ms |
384 KB |
Correct. |
20 |
Correct |
4 ms |
384 KB |
Correct. |
21 |
Correct |
4 ms |
384 KB |
Correct. |
22 |
Correct |
5 ms |
384 KB |
Correct. |
23 |
Correct |
4 ms |
384 KB |
Correct. |
24 |
Execution timed out |
10032 ms |
768 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |