# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
163221 |
2019-11-11T22:44:57 Z |
qkxwsm |
Sajam (COCI18_sajam) |
C++14 |
|
103 ms |
1444 KB |
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 1013
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
int N, K;
bitset<MAXN> grid[MAXN];
int freq[MAXN];
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cout << fixed << setprecision(12);
cerr << fixed << setprecision(4);
cin >> N >> K;
FOR(i, 0, N)
{
string temps; cin >> temps;
FOR(j, 0, N)
{
grid[i][j] = (temps[j] == 'o');
}
}
FOR(i, 0, N)
{
FOR(j, 0, N)
{
if (i == j) continue;
grid[j] ^= grid[i];
}
grid[i].reset();
int res = 0;
FOR(j, 0, N)
{
int x = grid[j].count();
res += min(x, N - x);
// FOR(k, 0, N)
// {
// cerr << grid[j][k] << ' ';
// }
// cerr << endl;
}
if (res <= K)
{
cout << "DA\n";
return 0;
}
}
if (N == K)
{
if (N == 4)
{
//wtf stupid case.
//try each of them as the changed guy.
FOR(i, 0, 2)
{
//toggle row 1.
FOR(j, 0, N) grid[0][j] = grid[0][j] ^ 1;
FOR(j, 0, 2)
{
//toggle row 2.
FOR(k, 0, N) grid[1][k] = grid[1][k] ^ 1;
FOR(k, 0, 2)
{
//toggle row 3.
//check if it's ok
FOR(m, 0, N) grid[2][m] = grid[2][m] ^ 1;
FOR(m, 0, N)
{
FOR(n, 0, N)
{
cerr << grid[m][n];
}
cerr << endl;
}
FOR(m, 0, N) freq[m] = 0;
bool ok = true;
FOR(m, 0, N - 1)
{
if (grid[m].count() != 2)
{
ok = false;
break;
}
int x = grid[m]._Find_first(), y = grid[m]._Find_next(x);
freq[x]++; freq[y]++;
}
if (!ok) continue;
// cerr << "OK\n";
sort(freq, freq + N);
FOR(i, 0, N - 1)
{
if (freq[i] != 1)
{
ok = false;
break;
}
}
if (ok)
{
cout << "DA\n";
return 0;
}
//ok now literally just check fi it works.
}
}
}
cout << "NE\n";
return 0;
}
// FOR(j, 0, N)
// {
// FOR(k, 0, N)
// {
// cerr << grid[j][k];
// }
// cerr << endl;
// }
FOR(j, 0, N - 1)
{
if (grid[j].count() != 2)
{
FOR(k, 0, N) grid[j][k] = grid[j][k] ^ 1;
}
if (grid[j].count() != 2)
{
cout << "NE\n";
return 0;
}
int x = grid[j]._Find_first(), y = grid[j]._Find_next(x);
// cerr << x << " -> " << y << endl;
freq[x]++; freq[y]++;
}
sort(freq, freq + N);
FOR(i, 0, N - 1)
{
if (freq[i] != 1)
{
cout << "NE\n";
return 0;
}
}
cout << "DA\n";
return 0;
}
//bleh now the N=K case
cout << "NE\n";
return 0;
//there has to be a row with <=1.
//fix a specific row and column.
//What's the minimum we could have on after a series of operations.
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
576 KB |
Output is correct |
4 |
Correct |
6 ms |
760 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
23 ms |
504 KB |
Output is correct |
8 |
Correct |
77 ms |
680 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
103 ms |
732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
4 ms |
504 KB |
Output is correct |
4 |
Correct |
4 ms |
504 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
26 ms |
504 KB |
Output is correct |
7 |
Correct |
47 ms |
504 KB |
Output is correct |
8 |
Correct |
51 ms |
616 KB |
Output is correct |
9 |
Correct |
17 ms |
504 KB |
Output is correct |
10 |
Correct |
85 ms |
644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
632 KB |
Output is correct |
3 |
Correct |
14 ms |
584 KB |
Output is correct |
4 |
Correct |
5 ms |
596 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
78 ms |
640 KB |
Output is correct |
7 |
Correct |
20 ms |
632 KB |
Output is correct |
8 |
Correct |
44 ms |
632 KB |
Output is correct |
9 |
Correct |
50 ms |
504 KB |
Output is correct |
10 |
Correct |
84 ms |
648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
84 ms |
640 KB |
Output is correct |
4 |
Correct |
27 ms |
760 KB |
Output is correct |
5 |
Correct |
39 ms |
888 KB |
Output is correct |
6 |
Correct |
77 ms |
1444 KB |
Output is correct |
7 |
Correct |
25 ms |
632 KB |
Output is correct |
8 |
Correct |
38 ms |
860 KB |
Output is correct |
9 |
Correct |
30 ms |
796 KB |
Output is correct |
10 |
Correct |
30 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
636 KB |
Output is correct |
2 |
Correct |
6 ms |
632 KB |
Output is correct |
3 |
Correct |
74 ms |
632 KB |
Output is correct |
4 |
Correct |
46 ms |
1016 KB |
Output is correct |
5 |
Correct |
46 ms |
1016 KB |
Output is correct |
6 |
Correct |
48 ms |
1056 KB |
Output is correct |
7 |
Correct |
27 ms |
632 KB |
Output is correct |
8 |
Correct |
67 ms |
1272 KB |
Output is correct |
9 |
Correct |
37 ms |
888 KB |
Output is correct |
10 |
Correct |
79 ms |
1400 KB |
Output is correct |