Submission #200955

#TimeUsernameProblemLanguageResultExecution timeMemory
200955SaboonSajam (COCI18_sajam)C++14
90 / 90
2275 ms2424 KiB
# include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; //# define int long long typedef long long ll; typedef pair<int, int> pii; typedef pair<double, int> pdi; typedef pair<ll, ll> pll; # define S second # define F first # define kill(x) return(cout << x << endl, 0LL) # define debug(x) cerr<< #x << " = " << x << endl # define ddebug(x, y) cerr<< #x << " = " << x << ", " << #y << " = " << y << endl # define tdebug(x, y, z) cerr<< #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl # define bin(x) cerr<< #x << " : " << bitset<4>(x) << endl # define sz(s) (int)s.size() # define sq(x) (x) * (x) # define PB(x) push_back(x) # define smax(x, y) (x) = max((x), (y)) # define smin(x, y) (x) = min((x), (y)) # define all(x) x.begin(), x.end() # define SP fixed << setprecision(10) # define MP make_pair # define uop(x, y) pii(min(x, y), max(x, y)) const int MAXN = 1000 + 10; bool a[MAXN][MAXN]; int sum[MAXN]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; for (int i = 0; i < n; i ++) for (int j = 0; j < n; j ++) { char c; cin >> c; a[i][j] = (c == 'x'); } for (int x = 0; x < n; x ++) { memset(sum, 0, sizeof sum); for (int j = 0; j < n; j ++) for (int i = 0; i < n; i ++) sum[i] += a[i][j] ^ a[x][j]; int s = 0; for (int i = 0; i < n; i ++) s += min(sum[i], n - sum[i]); if (s <= k) kill("DA"); } if (k != n) kill("NE"); for (int x = 0; x < n; x ++) { memset(sum, 0, sizeof sum); a[0][x] ^= 1; for (int j = 0; j < n; j ++) for (int i = 0; i < n; i ++) sum[i] += a[i][j] ^ a[0][j]; a[0][x] ^= 1; int s = 0; for (int i = 0; i < n; i ++) s += min(sum[i], n - sum[i]); if (s < k) kill("DA"); } cout << "NE" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...