QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805340 | #9871. Just another Sorting Problem | ucup-team135# | WA | 0ms | 3868kb | C++20 | 2.5kb | 2024-12-08 15:54:34 | 2024-12-08 15:54:36 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <fstream>
#include <array>
#include <functional>
#include <stack>
#include <memory>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define x first
#define y second
#define Time (double)clock()/CLOCKS_PER_SEC
#define munq(a) sort(all(a)); a.resize(unique(all(a))-a.begin())
#define sz(a) ((int)a.size())
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*1LL*u)%p;} else {int u=po(a,b-1);return (a*1LL*u)%p;}}
int inv(int x) {return po(x,p-2);}
mt19937 rnd;
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0)
#else
#define debug(...)
#define debugv(v)
#endif
#define lob(a,x) lower_bound(all(a),x)
#define upb(a,x) upper_bound(all(a),x)
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
cin >> t;
while (t--) {
int n;
string name;
cin >> n >> name;
vector <int> p(n);int nep = 0;
for (int i = 0; i < n; ++i) {
cin >> p[i];
p[i]--;
nep += p[i]==i;
}
if (n == 2 || (nep == 2 && name == "Alice")) {
cout << "Alice\n";
}
else if (n == 3) {
int par = 0;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < i; ++j) {
if (p[j] > p[i]) {
par ^= 1;
}
}
}
par ^= name == "Bob";
if (par) {
cout << "Alice\n";
}
else {
cout << "Bob\n";
}
}
else {
cout << "Bob\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
input:
3 2 Alice 2 1 3 Bob 1 3 2 10 Bob 1 2 3 4 5 6 7 8 10 9
output:
Alice Bob Bob
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
2 2 Alice 2 1 2 Bob 2 1
output:
Alice Alice
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
10 3 Bob 2 3 1 3 Alice 3 1 2 3 Bob 3 1 2 3 Alice 1 3 2 3 Alice 3 2 1 3 Bob 2 1 3 3 Bob 1 3 2 3 Alice 2 1 3 3 Alice 2 3 1 3 Bob 3 2 1
output:
Alice Bob Alice Alice Alice Bob Bob Alice Bob Bob
result:
ok 10 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
46 4 Alice 4 1 3 2 4 Bob 4 1 3 2 4 Bob 3 2 4 1 4 Bob 2 4 1 3 4 Bob 1 4 3 2 4 Bob 4 1 2 3 4 Alice 1 2 4 3 4 Alice 3 2 1 4 4 Bob 2 1 4 3 4 Bob 4 3 1 2 4 Alice 1 3 2 4 4 Bob 3 1 4 2 4 Bob 1 3 2 4 4 Alice 2 4 1 3 4 Bob 2 1 3 4 4 Alice 2 1 3 4 4 Bob 4 2 3 1 4 Bob 3 4 2 1 4 Alice 4 1 2 3 4 Bob 2 4 3 1 4 B...
output:
Bob Bob Bob Bob Bob Bob Alice Alice Bob Bob Alice Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob
result:
ok 46 lines
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
238 5 Alice 5 4 2 1 3 5 Bob 1 4 5 3 2 5 Bob 3 1 4 5 2 5 Alice 1 4 2 5 3 5 Bob 3 2 5 4 1 5 Alice 1 3 4 2 5 5 Bob 2 3 4 5 1 5 Bob 1 4 3 2 5 5 Bob 2 4 1 3 5 5 Bob 3 4 2 5 1 5 Alice 5 3 2 1 4 5 Bob 1 2 4 3 5 5 Alice 1 4 5 2 3 5 Alice 5 3 4 1 2 5 Alice 3 4 2 1 5 5 Alice 2 5 1 4 3 5 Alice 1 3 5 4 2 5 Alic...
output:
Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Alice Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob Bob ...
result:
wrong answer 6th lines differ - expected: 'Bob', found: 'Alice'