Submission #355571

# Submission time Handle Problem Language Result Execution time Memory
355571 2021-01-22T17:45:13 Z kshitij_sodani "The Lyuboyn" code (IZhO19_lyuboyn) C++14
16 / 100
658 ms 57404 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'
int n,k,t;
vector<vector<int>> solve(int n){
	if(n==1){
		return {{0},{1}};
		return {{0,0},{0,1},{1,1},{1,0}};
	}
	else{
		vector<vector<int>> aa=solve(n-1);
		vector<vector<int>> bb=solve(n-1);
		reverse(bb.begin(),bb.end());
		for(int i=0;i<aa.size();i++){
			aa[i].pb(0);
			bb[i].pb(1);
		}
		for(int i=0;i<bb.size();i++){
			aa.pb(bb[i]);
		}
		return aa;
	}
}
int it[20];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k>>t;
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		it[i]=s[i]-'0';
	}
	if(k==1 or k==n-1){
		vector<vector<int>> ans=solve(n);
		int ind=-1;
		int kk=0;
		if(k==n-1){
			kk=1;
		}
		for(int i=0;i<ans.size();i++){
			int st=1;
			for(int j=0;j<n;j++){
				if(ans[i][j]!=it[j]){
					st=0;
				}
			}
			if(st==1){
				ind=i;
			}
		}
		cout<<ans.size()<<endl;
	//	int cot=0;
		int cot=0;
		for(auto j:ans){
			for(int i=0;i<n;i++){
				if(cot==1 and kk==1){
					cout<<((it[i]^j[i])^1);
					continue;
				}
				cout<<(it[i]^j[i]);
			}
			cout<<endl;
			cot=1-cot;
		}
		/*for(int jj=ind;jj<ans.size();jj++){
			for(auto i:ans[jj]){
				cout<<(i);

			}
			cout<<endl;
			cot++;
		}
		for(int jj=0;jj<ind;jj++){
			for(auto i:ans[jj]){
				cout<<(i);
			}
			cout<<endl;
			cot++;
		}*/
	}
	else{
		cout<<-1<<endl;
		return 0;
		vector<vector<int>> ans=solve(k);
		vector<vector<int>> ans2=solve(n-k);
		for(int i=1;i<ans.size();i+=2){
			for(int j=0;j<k;j++){
				ans[i][j]^=1;
			}
		}
		int ind=0;
		int ind2=0;
		for(int i=0;i<(1<<n);i++){
			int coo=0;
			for(auto j:ans[ind]){
				cout<<(j^it[coo]);
				coo++;
			}
			for(auto j:ans2[ind2]){
				cout<<(j^it[coo]);
				coo++;
			}
			cout<<endl;
			ind++;
			ind2++;
			if(ind==ans.size()){
				ind=0;
			}
			if(ind2==ans2.size()){
				ind2=0;
			}
		}

	}
	
 
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'std::vector<std::vector<int> > solve(int)':
lyuboyn.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int i=0;i<aa.size();i++){
      |               ~^~~~~~~~~~
lyuboyn.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i=0;i<bb.size();i++){
      |               ~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:47:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i=0;i<ans.size();i++){
      |               ~^~~~~~~~~~~
lyuboyn.cpp:42:7: warning: variable 'ind' set but not used [-Wunused-but-set-variable]
   42 |   int ind=-1;
      |       ^~~
lyuboyn.cpp:93:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |   for(int i=1;i<ans.size();i+=2){
      |               ~^~~~~~~~~~~
lyuboyn.cpp:113:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |    if(ind==ans.size()){
      |       ~~~^~~~~~~~~~~~
lyuboyn.cpp:116:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  116 |    if(ind2==ans2.size()){
      |       ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Incorrect 1 ms 364 KB Found solution while it does not exist
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 658 ms 57404 KB Ok
2 Correct 313 ms 28108 KB Ok
3 Correct 2 ms 492 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 658 ms 57404 KB Ok
2 Correct 313 ms 28108 KB Ok
3 Correct 2 ms 492 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Incorrect 1 ms 364 KB Output -1 while solution exists
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -