Submission #776683

# Submission time Handle Problem Language Result Execution time Memory
776683 2023-07-08T07:04:48 Z vjudge1 Sajam (COCI18_sajam) C++17
60 / 90
5000 ms 2228 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);


 	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);

 		}

 	}

 	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[0][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;
	
		s[0][i]=(s[0][i]=='x'?'o':'x');
			val=tf;

	}


	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 104 ms 504 KB Output is correct
3 Correct 189 ms 596 KB Output is correct
4 Correct 1074 ms 1212 KB Output is correct
5 Correct 204 ms 612 KB Output is correct
6 Correct 46 ms 340 KB Output is correct
7 Correct 571 ms 596 KB Output is correct
8 Correct 4526 ms 1240 KB Output is correct
9 Correct 60 ms 364 KB Output is correct
10 Correct 4572 ms 1264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 2 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 618 ms 916 KB Output is correct
2 Correct 817 ms 1064 KB Output is correct
3 Correct 448 ms 800 KB Output is correct
4 Correct 366 ms 724 KB Output is correct
5 Correct 1141 ms 1108 KB Output is correct
6 Correct 216 ms 628 KB Output is correct
7 Correct 565 ms 904 KB Output is correct
8 Correct 656 ms 972 KB Output is correct
9 Correct 373 ms 484 KB Output is correct
10 Execution timed out 5029 ms 1364 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 961 ms 1120 KB Output is correct
2 Correct 927 ms 1112 KB Output is correct
3 Correct 384 ms 760 KB Output is correct
4 Correct 559 ms 896 KB Output is correct
5 Correct 637 ms 920 KB Output is correct
6 Correct 1394 ms 1304 KB Output is correct
7 Correct 150 ms 564 KB Output is correct
8 Correct 519 ms 868 KB Output is correct
9 Correct 2438 ms 920 KB Output is correct
10 Execution timed out 5041 ms 1364 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 423 ms 724 KB Output is correct
2 Correct 466 ms 772 KB Output is correct
3 Correct 1540 ms 1364 KB Output is correct
4 Correct 291 ms 928 KB Output is correct
5 Correct 442 ms 1200 KB Output is correct
6 Correct 1439 ms 2228 KB Output is correct
7 Correct 231 ms 896 KB Output is correct
8 Correct 262 ms 980 KB Output is correct
9 Correct 1139 ms 992 KB Output is correct
10 Correct 841 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1565 ms 1364 KB Output is correct
2 Correct 1523 ms 1324 KB Output is correct
3 Correct 1276 ms 1244 KB Output is correct
4 Correct 622 ms 1388 KB Output is correct
5 Correct 619 ms 1412 KB Output is correct
6 Correct 684 ms 1488 KB Output is correct
7 Correct 239 ms 920 KB Output is correct
8 Correct 1111 ms 1888 KB Output is correct
9 Correct 1433 ms 1168 KB Output is correct
10 Correct 4733 ms 2184 KB Output is correct