QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386227#7779. Swiss Stageiwew#WA 1ms3832kbC++201.3kb2024-04-11 14:18:592024-04-11 14:19:01

Judging History

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

  • [2024-04-11 14:19:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2024-04-11 14:18:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 110;

int dp[N], din[N];
int cost[N][N];

vector<pair<int, int>> adj[N];

void init() {
    int ed = 23;
    cost[0][0] = cost[0][1] = cost[1][0] = cost[0][2] = cost[2][0] = cost[1][1] = 1;
    cost[1][2] = cost[2][1] = cost[2][2] = 2;
    for(int i = 0; i <= 2; i ++ ) {
        for(int j = 0; j <= 2; j ++ ) {
            if(i + 1 == 3) {
                adj[ed].push_back({i * 10 + j, cost[i][j]});
                din[i * 10 + j] ++ ;
            } else {
                adj[(i + 1) * 10 + j].push_back({i * 10 + j, cost[i][j]});
                din[i * 10 + j] ++ ;
            }

            if(j + 1 < 3) {
                adj[i * 10 + j + 1].push_back({i * 10 + j, 1});
                din[i * 10 + j] ++ ;
            }
        }
    }

    for(int i = 0; i < N; i ++ ) dp[i] = 1e9;

    queue<int> que;
    que.push(ed);
    dp[ed] = 0;
    while(que.size()) {
        auto t = que.front();
        que.pop();
        for(auto [v, w] : adj[t]) {
            din[v] -- ;
            dp[v] = min(dp[v], dp[t] + w);
            if(din[v] == 0) que.push(v);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    init();

    int n, m;
    cin >> n >> m;
    cout << dp[n * 10 + m] << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3640kb

input:

0 1

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

1 2

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3640kb

input:

0 0

output:

3

result:

wrong answer 1st numbers differ - expected: '4', found: '3'