QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#801919#9871. Just another Sorting Problemucup-team5657#WA 0ms3612kbC++141.3kb2024-12-07 10:40:542024-12-07 10:40:54

Judging History

你现在查看的是最新测评结果

  • [2024-12-07 10:40:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-12-07 10:40:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline int lg2(int x){ return 31^__builtin_clz(x); }
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
void init(){ }

int n,p[100005],seq[100005],cnt;
string S;
unordered_map<int,int>mp;
void procedure(){
	mp.clear();
	cin>>n>>S;
	string T = (S=="Alice")?"Bob":"Alice";
	vector<int>v;
	for(int i=1;i<=n;i++) {
		int x; cin>>x; v.pb(x);
	}

	vector<int>q;
	for(int i=0;i<n;i++){
		if(v[i] != i+1) q.pb(i);
	}

	// cout<<q.size()<<" ok"<<endl;
	if(q.size() == 2 && (S == "Alice" || q[0]+1==q[1]) ){
		cout<<S<<"\n";
		return;
	}
	cout<<T<<"\n";
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T; cin>>T;
	init();
	while(T--) procedure();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

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: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

2
2 Alice
2 1
2 Bob
2 1

output:

Alice
Bob

result:

wrong answer 2nd lines differ - expected: 'Alice', found: 'Bob'