Cod sursa(job #2753874)

Utilizator mex7Alexandru Valentin mex7 Data 24 mai 2021 17:17:49
Problema Algoritmul Bellman-Ford Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t;
int v[100004];

bool isPalindrome(string s) {
	for (int i = 0; i < s.size() / 2; i++)
		if (s[i] != s[s.size() - 1 - i])
			return false;
	return true;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);

	cin >> t;
	for (int query = 1; query <= t; query++) {
		int n;
		string s;

		cin >> n;
		cin >> s;
		
		int cntZero = 0;
		for (char digit : s)
			if (digit == '0')
				cntZero++;
		
		if (isPalindrome(s))
			if (cntZero % 2 == 0 || cntZero == 1)
				cout << "BOB\n";
			else
				cout << "ALICE\n";
		else if (cntZero == 2 && n % 2 && s[n / 2] == '0')
			cout << "DRAW\n";
		else
			cout << "ALICE\n";
	}


	return 0;	
}