Submission #14091655


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T;
int N;
ll A[202];
string S;

template<class C> int gf2_rank(vector<C>& V) { /* input */
	int i,j;
	int N=V.size();
	FOR(i,N) {
		int x=max_element(V.begin()+i,V.end())-V.begin();
		if(V[x]==0) break;
		swap(V[i],V[x]);
		C msb=1;
		while(msb<<1 <= V[i]) msb<<=1;
		FOR(j,N) if(j!=i) if(V[j]&msb) V[j]^=V[i];
	}
	sort(ALL(V));
	reverse(ALL(V));
	while(V.size() && V.back()==0) V.pop_back();
	return V.size();
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	while(T--) {
		cin>>N;
		vector<ll> V;
		FOR(i,N) cin>>A[i];
		cin>>S;
		
		for(i=N-1;i>=0;i--) {
			if(S[i]=='0') {
				V.push_back(A[i]);
				gf2_rank(V);
			}
			else {
				x=V.size();
				V.push_back(A[i]);
				gf2_rank(V);
				if(V.size()>x) break;
				
			}
		}
		if(i>=0) cout<<1<<endl;
		else cout<<0<<endl;
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task A - Xor Battle
User kmjp
Language C++ (GCC 9.2.1)
Score 400
Code Size 1545 Byte
Status AC
Exec Time 86 ms
Memory 3612 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:57:16: warning: comparison of integer expressions of different signedness: ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   57 |     if(V.size()>x) break;
      |        ~~~~~~~~^~
./Main.cpp:39:8: warning: unused variable ‘j’ [-Wunused-variable]
   39 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:39:10: warning: unused variable ‘k’ [-Wunused-variable]
   39 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:39:12: warning: unused variable ‘l’ [-Wunused-variable]
   39 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:39:14: warning: unused variable ‘r’ [-Wunused-variable]
   39 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:39:18: warning: unused variable ‘y’ [-Wunused-variable]
   39 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:7:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    7 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:71:38: note: in expansion of macro ‘FOR’
   71 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 3
Set Name Test Cases
Sample 00-sample-01.txt
All 00-sample-01.txt, 01-01.txt, 01-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 2 ms 3496 KB
01-01.txt AC 86 ms 3508 KB
01-02.txt AC 56 ms 3612 KB