Submission #776678

# Submission time Handle Problem Language Result Execution time Memory
776678 2023-07-08T06:59:09 Z vjudge1 Sajam (COCI18_sajam) C++17
15 / 90
4646 ms 2308 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+37;

		
void f(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 
	//f();
 	
 	int n, k; cin >> n >> k;

 	vector<string> s(n), t;
 	vector<int> val(n), val2(n);


 	for(auto &i: s) cin >> i;

 	for(int i=0; i<n; i++){
 		for(int l=0; l<n; l++){
 			val[i]+=((s[i][l]=='x')?1:0);
 			 val2[l]+=((s[i][l]=='x')?1:0);

 		}

 	}

 	int flag=0;

	for(int i=0; i<n; i++){
		vector<int> tf=val;

		for(int l=0; l<n; l++){
			if(s[i][l]=='x'){
				for(int j=0; j<n; j++){
					if(s[j][l]=='x'){
						val[j]--;
					}
					else val[j]++;
				}
			}
		}

		int ans=0;
		for(int l=0; l<n; l++){
			ans+=min(val[l], n-val[l]);
		}
		if(ans<=k) flag=1;
		val=tf;
	}
	
	k--;

	for(int i=0; i<n; i++){
		vector<int> tf=val;
		if(s[0][i]=='x') val[0]--;
		else val[0]++;
		s[0][i]=(s[0][i]=='x'?'o':'x');

		for(int l=0; l<n; l++){
			if(s[i][l]=='x'){
				for(int j=0; j<n; j++){
					if(s[j][l]=='x'){
						val[j]--;
					}
					else val[j]++;
				}
			}
		}

		int ans=0;
		for(int l=0; l<n; l++){
			ans+=min(val[l], n-val[l]);
		}
		if(ans<=k) flag=1;
		val=tf;
				if(s[0][i]=='x') val[0]--;
		else val[0]++;
		s[0][i]=(s[0][i]=='x'?'o':'x');

	}


	if(flag) cout<<"DA";
	else cout<<"NE";

}

Compilation message

sajam.cpp: In function 'void f()':
sajam.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sajam.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 98 ms 632 KB Output is correct
3 Correct 163 ms 724 KB Output is correct
4 Correct 933 ms 1336 KB Output is correct
5 Correct 172 ms 724 KB Output is correct
6 Correct 42 ms 468 KB Output is correct
7 Correct 577 ms 616 KB Output is correct
8 Correct 4456 ms 1372 KB Output is correct
9 Correct 63 ms 416 KB Output is correct
10 Correct 4646 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Incorrect 2 ms 324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 564 ms 1052 KB Output is correct
2 Correct 753 ms 1744 KB Output is correct
3 Correct 404 ms 1256 KB Output is correct
4 Correct 339 ms 1140 KB Output is correct
5 Correct 974 ms 1984 KB Output is correct
6 Incorrect 222 ms 912 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 866 ms 1252 KB Output is correct
2 Correct 843 ms 1832 KB Output is correct
3 Correct 342 ms 1176 KB Output is correct
4 Correct 489 ms 1416 KB Output is correct
5 Correct 548 ms 1480 KB Output is correct
6 Incorrect 1277 ms 2220 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 381 ms 900 KB Output is correct
2 Correct 404 ms 1192 KB Output is correct
3 Incorrect 1367 ms 2308 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1418 ms 1516 KB Output is correct
2 Correct 1288 ms 2260 KB Output is correct
3 Incorrect 1175 ms 2112 KB Output isn't correct
4 Halted 0 ms 0 KB -