답안 #776787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776787 2023-07-08T09:25:49 Z vjudge1 Sajam (COCI18_sajam) C++17
0 / 90
1 ms 468 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
int arr[105][105];
int n,k;
ll int qsef(int x,int hangi){
	if(x>=n&&hangi==0)return qsef(0,1);
	if(x==n&&hangi){
		int bir=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				bir+=arr[i][j];
				//cout<<arr[i][j]<<" ";
			}//cout<<endl;
		}

		return bir;
	}
	int bir=0;
	for(int i=0;i<n;i++){
		if(hangi==0)bir+=arr[x][i];
		else bir+=arr[i][x];
	}
	//cout<<x<<" "<<hangi<<" "<<bir<<endl;
	int ands;
	if(bir>=n/2){
		for(int i=0;i<n;i++){
			if(hangi==0){
				arr[x][i]^=1;
				//cout<<arr[x][i]<<" ";
			}
			else{ 	
				arr[i][x]^=1;  //cout<<arr[i][x]<<" ";
			}
			
		}
		//cout<<endl;
		ands=qsef(x+1,hangi);
		if(bir>n/2)return ands;
	}
	int aaa;
	if(bir<=n/2){
		for(int i=0;i<n;i++){
			for(int i=0;i<n;i++){
				if(hangi==0){
					arr[x][i]^=1;
					//cout<<arr[x][i]<<" ";
				}
				else{
					arr[i][x]^=1;  //cout<<arr[i][x]<<" ";
				}
			
			}
			//cout<<endl;
			
		}
		aaa=qsef(x+1,hangi);
		if(bir<n/2)return aaa;
	}
	//cout<<x<<" "<<hangi<<" "<<ands<<" "<<aaa<<endl;
	return min(ands,aaa);
}
int main(){
	lalala;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		string str;cin>>str;

		for(int j=0;j<n;j++){
			if(str[j]=='x')arr[i][j]=0;
			else arr[i][j]=1;
		}
	}
	int a=qsef(0,0);
	if(a<=k)cout<<"DA"<<endl;
	else cout<<"NE"<<endl;
}

Compilation message

sajam.cpp: In function 'long long int qsef(int, int)':
sajam.cpp:28:6: warning: 'ands' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |  int ands;
      |      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -