답안 #1035627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035627 2024-07-26T12:36:20 Z vjudge1 World of Tank (innopolis2018_final_E) C++17
30 / 100
1 ms 488 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6+2;

int n, m0, m1, t;
queue<int> q[2];
bitset<N> obstacle[2];
vector<int> c;
vector<pair<int, int>> s;

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> m0 >> m1 >> t;
  for (int i = 0; i < m0; i++) {
    int x; cin >> x;
    q[0].push(x);
    obstacle[0][x] = 1;
  }
  for (int i = 0; i < m1; i++) {
    int x; cin >> x;
    q[1].push(x);
    obstacle[1][x] = 1;
  }

  bool ok = 1; // can i reach the end?
  int lane = 0; // in which line am i
  int lastX = 0; // first x since the lane change
  int lastShot = -1; // when was the last shot
  for (int i = 0; i < n+1; i++) {
    //cerr << i << " " << ok << " " << lane << " " << lastX << " " << lastShot << endl;
    while (!q[lane].empty() && q[lane].front() <= i) q[lane].pop();
    while (!q[!lane].empty() && q[!lane].front() < i) q[!lane].pop();

    while (!q[0].empty() && !q[1].empty() && q[0].front() == q[1].front()) {
      q[0].pop();
      q[1].pop();
    }
    
    // cambio de linea?
    if (!obstacle[!lane][i] && !q[lane].empty() && (q[!lane].empty() || q[!lane].front() > q[lane].front())) {
      c.push_back(i);
      lane = !lane;
      lastX = i;
    }

    // disparo?
    if (obstacle[lane][i+1]) {
      int x = max(lastX, lastShot+t);
      if (x > i) {
        ok = 0;
        break;
      }
      else {
        s.push_back(make_pair(x, lane));
        lastShot = x;
      }
    }
  }

  if (!ok) {
    cout << "No\n";
  }
  else {
    cout << "Yes\n";

    int sz = c.size();
    cout << sz << "\n";
    for (int& i : c) cout << i << " ";
    cout << "\n";

    sz = s.size();
    cout << sz << "\n";
    for (auto& [i, j] : s) cout << i << " " << j+1 << "\n";
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 1 ms 344 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 1 ms 344 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 0 ms 488 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 0 ms 480 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB [No solution found] n = 20, m1 = 12, m2 = 9, t = 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 1 ms 344 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 0 ms 488 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 0 ms 480 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
24 Incorrect 0 ms 348 KB [No solution found] n = 500, m1 = 197, m2 = 53, t = 2
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB [OK, Yes] n = 20, m1 = 20, m2 = 0, t = 20
2 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 509, m2 = 491, t = 5000
3 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 764, m2 = 736, t = 5000
4 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 698, m2 = 802, t = 5000
5 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 720, m2 = 780, t = 5000
6 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 734, m2 = 766, t = 5000
7 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 997, m2 = 1003, t = 5000
8 Correct 0 ms 348 KB [OK, Yes] n = 5000, m1 = 1021, m2 = 979, t = 5000
9 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1006, m2 = 995, t = 5000
10 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1017, m2 = 984, t = 5000
11 Correct 1 ms 344 KB [OK, No] n = 5000, m1 = 1495, m2 = 1506, t = 5000
12 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 974, m2 = 1026, t = 2501
13 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1022, m2 = 978, t = 2501
14 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1019, m2 = 981, t = 2501
15 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1298, m2 = 1367, t = 2501
16 Correct 0 ms 488 KB [OK, No] n = 5000, m1 = 1301, m2 = 1360, t = 2501
17 Correct 1 ms 348 KB [OK, Yes] n = 5000, m1 = 1320, m2 = 1315, t = 2501
18 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1195, m2 = 1135, t = 2501
19 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1148, m2 = 1202, t = 2501
20 Correct 0 ms 480 KB [OK, No] n = 5000, m1 = 1147, m2 = 1179, t = 2501
21 Correct 1 ms 348 KB [OK, No] n = 5000, m1 = 1163, m2 = 1146, t = 2501
22 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1145, m2 = 1184, t = 2501
23 Correct 0 ms 348 KB [OK, No] n = 5000, m1 = 1172, m2 = 1150, t = 2501
24 Incorrect 1 ms 348 KB [No solution found] n = 20, m1 = 12, m2 = 9, t = 3
25 Halted 0 ms 0 KB -