QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#612751 | #8230. Submissions | Hans# | WA | 1ms | 3688kb | C++23 | 1.1kb | 2024-10-05 12:48:37 | 2024-10-05 12:48:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
struct lamp {
int x;
int color;
};
struct lamp lamps[250000] = {};
int xAxis[250000] = {};
int main(void) {
int n, q, maxX;
cin >> n >> q;
// Get all lamps
for (int i = 1; i <= n; i++) {
// Append lamp to lamps arr
cin >> lamps[i].x >> lamps[i].color;
// Place lamps in the x axis
xAxis[lamps[i].x] = i;
maxX = max(maxX, lamps[i].x);
}
// for (int x = 0; x < i; x++)
// printf("Lamps { x: %d, y: %d}\n", lamps[x].x, lamps[x].color);
// Solve queries
for (int i = 0; i < q; i++) {
bool found = false;
int d; cin >> d;
// For i in lamp
for (int j = 1; j <= n && !found; j++) {
// Check if lamp id is in bounds
if (lamps[j].x + d > maxX) continue;
// Check if lamp is valid
int otherLamp = xAxis[lamps[j].x + d];
if (!otherLamp) continue;
if (lamps[otherLamp].color != lamps[j].color) {
cout << j << endl;
found = true;
}
}
if (!found)
cout << 0 << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3688kb
input:
2 5 TSxingxing10 G 0 rejected TSxingxing10 B 83 accepted aoliaoligeiliao J 98 accepted TS1 J 118 accepted TS1 B 263 accepted 12 AllWayTheNorth A 0 rejected YaoYaoLingXian Y 10 accepted XuejunXinyoudui1 X 200 rejected XuejunXinyoudui1 X 200 accepted LetItRot L 215 accepted AllWayTheNorth W 250 accept...
output:
0 0 0 0 0
result:
wrong answer Integer parameter [name=n] equals to 0, violates the range [1, 100000] (test case 1)