1747C - Swap Game - CodeForces Solution


games

Please click on ads to support us..

Python Code:

t = int(input())

for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    print("Alice" if min(a) != a[0] else "Bob")

C++ Code:

//MANISHk
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define db double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define frr(i, k, n) for (int i = n - 1; i >= k; i--)
#define fr(i, k, n) for (int i = k; i < n; i++)


long long f(int a, int b) {
if(b == 0) return 1;
long long p = f(a,b/2);
if(b%2==0) return (p*p)%1000000007;
else return (((p*p)%1000000007) * a) % 1000000007;
}


ll gcd(ll a, ll b){
if (a == 0)
return b;
if (b == 0)
return a;
if (a < b)
return gcd(a, b % a);
return gcd(b, a % b);
}

ll lcm (ll a , ll b){
return (a*b) / gcd(a , b);
}

bool isperfect(double n){
if(n >= 0){
ll x = sqrt(n);
return (x*x == n);
}
else
return false;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll gcdExtended(ll a, ll b, ll *x, ll *y);

ll modInverse(ll b, ll m){
ll x, y;
ll g = gcdExtended(b, m, &x, &y);
if (g != 1)
return -1;
return (x%m + m) % m;
}

ll modDivide(ll a, ll b, ll m){
a = a % m;
ll inv = modInverse(b, m);
return (inv * a) % m;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
if (a == 0){
*x = 0, *y = 1;
return b;
}

ll x1;ll y1;
ll gcd = gcdExtended(b%a, a, &x1, &y1);

*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void solve(){
    ll n;
    cin>>n;
ll a[n];
ll mn=INT_MAX;
for(ll i=0;i<n;i++){
    cin>>a[i];
    mn=min(mn,a[i]);
}
if(a[0]>mn)cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
ll t;
cin>>t;
while(t--){
solve();
}
}


Comments

Submit
0 Comments
More Questions

1715D - 2+ doors
267A - Subtractions
1582A - Luntik and Concerts
560A - Currency System in Geraldion
946A - Partition
1068B - LCM
1692E - Binary Deque
679A - Bear and Prime 100
488A - Giga Tower
14A - Letter
1150A - Stock Arbitraging
1552A - Subsequence Permutation
1131F - Asya And Kittens
1475F - Unusual Matrix
133B - Unary
1547A - Shortest Path with Obstacle
624A - Save Luke
1238A - Prime Subtraction
1107C - Brutality
1391B - Fix You
988B - Substrings Sort
312A - Whose sentence is it
513A - Game
1711E - XOR Triangle
688A - Opponents
20C - Dijkstra
1627D - Not Adding
893B - Beautiful Divisors
864B - Polycarp and Letters
1088A - Ehab and another construction problem