QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#822206#9871. Just another Sorting ProblemLeoGWA 1ms3788kbC++233.2kb2024-12-20 00:22:432024-12-20 00:22:44

Judging History

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

  • [2024-12-20 00:22:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3788kb
  • [2024-12-20 00:22:43]
  • 提交

answer

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <numeric>

#define ll              long long 
#define all(v)          v.begin(),v.end()
#define ld              long double
#define pll             std::pair<ll,ll>
#define pi              std::pair<int,int>
#define vi              std::vector<int>
#define vll             std::vector<ll>
#define len(x)          (int)x.size()
#define vec(T)          std::vector<T>

// overload << for pair
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::pair<T, T>& pair) {
    std::cout << "(" << pair.first << ", " << pair.second << ")";
    return os;
}


// overload << for vec
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
    os << "[";
    for (size_t i = 0; i < vec.size(); ++i) {
        os << vec[i] << (i == vec.size() - 1 ? "\0" : ", ");
    }
    os << "]";
    return os;
}


// overload << for map and unordered_map Output
template<typename Map>
void printMap(const Map& m) {
    std::cout << '{';
    for (auto it = m.begin(); it != m.end(); it++) {
        std::cout << it -> first << ": " << it -> second << (std::next(it) == m.end() ? "\0" : ", ");
    }
    std::cout << "}";
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
    printMap(m);
    return os;
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V>& m) {
    printMap(m);
    return os;
}

// overload << for set and unordered_set Output
template<typename Set>
void printSet(const Set& s) {
    std::cout << '{';
    for (auto it = s.begin(); it != s.end(); it++) {
        std::cout << *it << (std::next(it) == s.end() ? "\0" : ", ");
    }
    std::cout << "}";
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
    printSet(s);
    return os;
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& s) {
    printSet(s);
    return os;
}

// General print function
template <typename T>
void print(const T& val) {
    std::cout << val << std::endl;
}

// Variadic template print function
template<typename T, typename... Args>
void print(const T& t, const Args&... args) {
    std::cout << t << ' ';
    print(args...);
    if (sizeof...(args) == 1) std::cout << '\n';

}

void solve(){  
    int n;
    std::string player;
    std::cin >> n >> player;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++) std::cin >> a[i];
    if (n == 2) {
        std::cout << "Alice\n";
        return;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cnt += (a[i] != i + 1);
    }
    if (cnt == 2 && player == "Alice") {
        std::cout << "Alice\n";
    }
    else {
        std::cout << "Bob\n";
    }
}



    
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t = 1;
    std::cin >> t;
    while (t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3788kb

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: 3604kb

input:

2
2 Alice
2 1
2 Bob
2 1

output:

Alice
Alice

result:

ok 2 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3648kb

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:

Bob
Bob
Bob
Alice
Alice
Bob
Bob
Alice
Bob
Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'