Submission #776643

# Submission time Handle Problem Language Result Execution time Memory
776643 2023-07-08T06:27:59 Z vjudge1 Sajam (COCI18_sajam) C++17
45 / 90
47 ms 4308 KB
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 1005

bitset<N> arr[N];
int dist[N][N];
const int INF = 2e9 + 7;

int32_t main(){
	#ifndef ONLINE_JUDGE
	//fileio();
	#endif
	fastio();

	int n, k;
	cin>>n>>k;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			char c;
			cin>>c;
			arr[i][j] = c == 'x';
		}
	}

	for (int i = 1; i <= n; i++){
		for (int j = i + 1; j <= n; j++){
			bitset<N> tmp = arr[i] ^ arr[j];
			dist[i][j] = dist[j][i] = tmp.count();
		}
	}

	int ans = INF;
	for (int i = 1; i <= n; i++){
		int curr = 0;
		for (int j = 1; j <= n; j++){
			curr += min(dist[i][j], n - dist[i][j]);
		}
		ans = min(ans, curr);
	}

	for (int i = 1; i <= n; i++){
		int curr = 1;
		for (int j = 2; j <= n; j++){
			if (arr[j][i] == arr[1][i]) dist[1][j]++;
			else dist[1][j]--;
			curr += min(dist[1][j], n - dist[1][j]);
			if (arr[j][i] == arr[1][i]) dist[1][j]--;
			else dist[1][j]++;
		}
	}
	if (ans <= k) cout<<"DA\n";
	else cout<<"NE\n";
	//cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 7 ms 2044 KB Output is correct
3 Correct 11 ms 2412 KB Output is correct
4 Correct 32 ms 4016 KB Output is correct
5 Correct 11 ms 2444 KB Output is correct
6 Correct 5 ms 1644 KB Output is correct
7 Correct 10 ms 2260 KB Output is correct
8 Correct 34 ms 4108 KB Output is correct
9 Correct 3 ms 1236 KB Output is correct
10 Correct 36 ms 4052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 1 ms 596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3284 KB Output is correct
2 Correct 27 ms 3584 KB Output is correct
3 Correct 18 ms 3052 KB Output is correct
4 Correct 16 ms 2916 KB Output is correct
5 Correct 38 ms 3964 KB Output is correct
6 Correct 12 ms 2396 KB Output is correct
7 Correct 22 ms 3332 KB Output is correct
8 Correct 23 ms 3408 KB Output is correct
9 Correct 7 ms 1876 KB Output is correct
10 Correct 39 ms 4308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3796 KB Output is correct
2 Correct 34 ms 3924 KB Output is correct
3 Correct 17 ms 2900 KB Output is correct
4 Correct 21 ms 3240 KB Output is correct
5 Correct 22 ms 3416 KB Output is correct
6 Correct 47 ms 4200 KB Output is correct
7 Correct 10 ms 2260 KB Output is correct
8 Correct 21 ms 3224 KB Output is correct
9 Correct 23 ms 3304 KB Output is correct
10 Correct 39 ms 4284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2964 KB Output is correct
2 Correct 17 ms 2980 KB Output is correct
3 Incorrect 38 ms 4308 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 4308 KB Output is correct
2 Correct 37 ms 4272 KB Output is correct
3 Incorrect 34 ms 4092 KB Output isn't correct
4 Halted 0 ms 0 KB -