QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#386213 | #7779. Swiss Stage | iwew# | WA | 1ms | 3800kb | C++20 | 1.4kb | 2024-04-11 14:08:11 | 2024-04-11 14:08:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 55;
int dp[N], din[N];
int cost[N][N];
vector<pair<int, int>> adj[N];
void init() {
int ed = 23;
int dx[2] = {0, 1};
int dy[2] = {1, 0};
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 ++ ) {
for(int k = 0; k < 2; k ++ ) {
int x = i + dx[k], y = j + dy[k];
if(x == 3) {
adj[ed].push_back({i * 10 + j, cost[i][j]});
din[i * 10 + j] ++ ;
} else if(y < 3) {
adj[x * 10 + y].push_back({i * 10 + j, cost[i][j]});
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: 3636kb
input:
0 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 2
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3492kb
input:
0 0
output:
3
result:
wrong answer 1st numbers differ - expected: '4', found: '3'