QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#815932 | #9871. Just another Sorting Problem | tamir# | Compile Error | / | / | C++20 | 964b | 2024-12-15 19:04:57 | 2024-12-15 19:04:57 |
Judging History
answer
#include<iostream>
using namespace std;
void solve() {
int n; string st;
cin >> n >> st;
vector<int> a(n);
int cnt = 0;
for(int i = 0; i < n; i++) {
cin >> a[i];
a[i]--;
if(a[i] != i) {
cnt++;
}
}
if(st == "Alice") {
if(cnt <= 2) {
cout << "Alice\n";
return;
}
} else {
int mx = 0;
for(int i = 1; i < n; i++){
int t = cnt;
//(i - 1, i)
if(a[i - 1] == i - 1)t++;
if(a[i] == i)t++;
if(a[i] == i - 1)t--;
if(a[i - 1] == i)t--;
mx = max(mx, t);
}
if(mx >= 3){
cout << "Bob\n";
} else {
cout << "Alice\n";
}
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(nullptr);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:8:5: error: ‘vector’ was not declared in this scope 8 | vector<int> a(n); | ^~~~~~ answer.code:2:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’? 1 | #include<iostream> +++ |+#include <vector> 2 | using namespace std; answer.code:8:12: error: expected primary-expression before ‘int’ 8 | vector<int> a(n); | ^~~ answer.code:11:16: error: ‘a’ was not declared in this scope 11 | cin >> a[i]; | ^ answer.code:27:16: error: ‘a’ was not declared in this scope 27 | if(a[i - 1] == i - 1)t++; | ^ answer.code:28:16: error: ‘a’ was not declared in this scope 28 | if(a[i] == i)t++; | ^ answer.code:29:16: error: ‘a’ was not declared in this scope 29 | if(a[i] == i - 1)t--; | ^ answer.code:30:16: error: ‘a’ was not declared in this scope 30 | if(a[i - 1] == i)t--; | ^