QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612751#8230. SubmissionsHans#WA 1ms3688kbC++231.1kb2024-10-05 12:48:372024-10-05 12:48:38

Judging History

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

  • [2024-10-05 12:48:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3688kb
  • [2024-10-05 12:48:37]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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)