QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#281422#7184. Transport Plusesikaurov#WA 130ms4456kbC++203.4kb2023-12-10 04:52:572023-12-10 04:52:57

Judging History

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

  • [2023-12-10 04:52:57]
  • 评测
  • 测评结果:WA
  • 用时:130ms
  • 内存:4456kb
  • [2023-12-10 04:52:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef long double ld;
const ld PI = acosl(-1);
const ll mod7 = 1e9 + 7;
const ll mod9 = 998244353;
const ll INF = 2 * 1024 * 1024 * 1023;
const char nl = '\n';
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define all(v) v.begin(),v.end()
#pragma GCC optimize("O2")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
 
ll l, r, k, n, m, p, q, u, v, w, x, y, z;
string s, t;
 
vi d4x = {1, 0, -1, 0};
vi d4y = {0, 1, 0, -1};
vi d8x = {1, 0, -1, 0, 1, 1, -1, -1};
vi d8y = {0, 1, 0, -1, 1, -1, 1, -1};

bool multiTest = 0;
void solve(int tt) {

  double cost;
  cin >> n >> cost;

  double dist[101][101];
  forn(i, 101) forn(j, 101) dist[i][j] = 1e18;

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int xStart = x1;
  int yStart = y1;

  dist[x1][y1] = 0;
  
  vi covered[101][101];

  vector<pii> points;

  forn(i, n) {
    cin >> x1 >> y1;
    points.push_back({x1, y1});
    forn(j, 101) {
      covered[x1][j].push_back(i);
      if(j != x1) covered[j][y1].push_back(i);
    }
  }

  int visited[101][101];
  memset(visited, 0, sizeof(visited));

  array<int, 3> br[101][101];

  double precomputeSqrt[20010];
  for(int i = 1; i <= 20000; i++) {
    precomputeSqrt[i] = sqrtl(i);
  }

  while(true) {
    double bestDist = 1e18;
    int curX = -1;
    int curY = -1;

    forn(i, 101) {
      forn(j, 101) {
        if(visited[i][j]) continue;
        if(dist[i][j] < bestDist) {
          bestDist = dist[i][j];
          curX = i;
          curY = j;
        }
      }
    }


    if(curX == -1) break;

    forn(i, 101) {
      forn(j, 101) {
        double nextCost = precomputeSqrt[(curX - i) * (curX - i) + (curY - j) * (curY - j)];
        if(dist[i][j] > bestDist + nextCost) {
          dist[i][j] = bestDist + nextCost;
          br[i][j] = {0, curX, curY};
        }
      }
    }

    for(int z : covered[curX][curY]) {
      forn(i, 101) {
        if(dist[points[z].first][i] > bestDist + cost) {
            dist[points[z].first][i] = bestDist + cost;
            br[points[z].first][i] = {1, curX, curY};
        }
        if(dist[i][points[z].second] > bestDist + cost) {
            dist[i][points[z].second] = bestDist + cost;
            br[i][points[z].second] = {1, curX, curY};
        }
      }
    }

    visited[curX][curY] = 1;
  }

  cout << dist[x2][y2] << nl;

  int curX = x2;
  int curY = y2;
  vector<array<int, 3>> moves;

  while(true) {
    moves.push_back({br[curX][curY][0], curX, curY});
    int prevX = curX;
    curX = br[prevX][curY][1];
    curY = br[prevX][curY][2];
    if(curX == xStart && curY == yStart) break;
  }

  cout << moves.size() << nl;
  reverse(all(moves));
  for(auto z : moves) cout << z[0] << ' ' << z[1] << ' ' << z[2] << nl;
}
 
int main() {
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    cout << fixed << setprecision(14);

    int t = 1;
    if (multiTest) cin >> t;
    for (int ii = 0; ii < t; ii++) {
        solve(ii);
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 126ms
memory: 4448kb

input:

1 2
1 1
5 3
6 2

output:

4.00000000000000
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 130ms
memory: 4456kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2.00000000000000
2
1 0 3
1 6 1

result:

wrong answer step 2: target (6.000000, 1.000000) not on plus (1.000000, 3.000000)