QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#386227 | #7779. Swiss Stage | iwew# | WA | 1ms | 3832kb | C++20 | 1.3kb | 2024-04-11 14:18:59 | 2024-04-11 14:19:01 |
Judging History
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;
}
詳細信息
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'