fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define int long long
  5. #define all(x) x.begin(), x.end()
  6. #define siz(x) ((int)x.size())
  7. #define yes cout << "YES\n"
  8. #define no cout << "NO\n"
  9. #define f first
  10. #define s second
  11.  
  12.  
  13.  
  14. const int mod = 1e9+7;
  15. const int N = 500004;
  16. const long long inf = 1e18+12;
  17. double eps = 1e-9;
  18. bitset<N>x;
  19.  
  20. string hi (string& s) {
  21. int n = s.size();
  22. int a = 0;
  23. for (int i=n-1; i>=0; i--) {
  24. if ( s[i] == 'A' ) a++;
  25. else a--;
  26. if ( a > 0 ) return "Alice";
  27. }
  28. return "Bob";
  29. }
  30.  
  31. signed main () {
  32. ios::sync_with_stdio(false);
  33. cin.tie(0);
  34. freopen( "crash_course_input.txt", "r", stdin );
  35. freopen( "crash_course_output.txt", "w", stdout );
  36. int t=1;
  37. cin >> t;
  38. //pre();
  39. //cout << fixed << setprecision(9);
  40. for (int cse = 1; cse <= t; cse++) {
  41. int n; cin >> n;
  42. string s; cin >> s;
  43. cout << "Case #" << cse << ": " << hi(s) << "\n";
  44. }
  45.  
  46. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty