QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834610 | #8722. 卡牌游戏 | GPT-ofast# | Compile Error | / | / | D | 2.2kb | 2024-12-27 20:55:53 | 2024-12-27 20:55:53 |
Judging History
This is the latest submission verdict.
- [2024-12-27 20:55:53]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-27 20:55:53]
- Submitted
answer
import std.stdio;
import std.algorithm;
import std.array;
import std.math;
import std.string;
// Entry point of the program
void main() {
// Read all input at once for efficiency
string data = stdin.readAll();
// Split the input into tokens based on whitespace
auto tokens = data.split!(c => c == ' ' || c == '\n' || c == '\r' || c == '\t')
.filter!(s => s.length > 0)
.array;
int ptr = 0; // Pointer to keep track of the current token
// Read the number of test cases
int t = tokens[ptr++].to!int;
// Process each test case
while (t-- > 0) {
// Read the value of n
int n = tokens[ptr++].to!int;
// Read array a
int[] a = new int[n];
foreach (i; 0 .. n) {
a[i] = tokens[ptr++].to!int;
}
// Read array b
int[] b = new int[n];
foreach (i; 0 .. n) {
b[i] = tokens[ptr++].to!int;
}
// Initialize arrays c, d, and p
int[] c = new int[n];
int[] d = new int[n];
int[] p = new int[n];
foreach (i; 0 .. n) {
c[i] = min(a[i], b[i]);
d[i] = a[i] - b[i];
p[i] = i; // Initialize p with indices 0 to n-1
}
// Sort the indices in p based on the comparator
p.sortWith!((x, y) {
if (c[x] > c[y]) return -1; // Descending order for c
if (c[x] < c[y]) return 1;
if (d[x] < d[y]) return -1; // Ascending order for d if c is equal
if (d[x] > d[y]) return 1;
return 0;
});
// Determine the result based on the sorted indices
string result;
if (d[p[0]] < 0) {
result = "Alice";
}
else if (n >= 2 && c[p[0]] == c[p[1]]) {
result = "Bob";
}
else if (d[p[0]] == 0) {
result = "Alice";
}
else if (d[p[0]] >= 0 && (n < 2 || (n >= 2 && d[p[1]] >= 0))) {
result = "Bob";
}
else {
result = "Alice";
}
// Output the result for the current test case
writeln(result);
}
}
詳細信息
answer.d(10): Error: no property `readAll` for `makeGlobal()` of type `std.stdio.File` /usr/include/dmd/phobos/std/stdio.d(527): struct `File` defined here answer.d(20): Error: no property `to` for type `string`, perhaps `import std.conv;` is needed? answer.d(25): Error: no property `to` for type `string`, perhaps `import std.conv;` is needed? answer.d(30): Error: no property `to` for type `string`, perhaps `import std.conv;` is needed? answer.d(36): Error: no property `to` for type `string`, perhaps `import std.conv;` is needed? answer.d(50): Error: no property `sortWith` for `p` of type `int[]`