結果
| 問題 |
No.1465 Archaea
|
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2021-04-02 21:39:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 977 bytes |
| コンパイル時間 | 2,182 ms |
| コンパイル使用メモリ | 175,056 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2024-12-23 18:39:48 |
| 合計ジャッジ時間 | 2,868 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 WA * 1 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main() {
int N,K;
cin >> N >> K;
vector<int>dist(N+1,INF);
vector<vector<pair<int,int>>>road(N+1);
for(int i = 1; i <= N; i++) {
if(i*2 <= N) {
road[i].push_back({i*2,1});
}
if(i+3 <= N) {
road[i].push_back({i+3,1});
}
}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
que.push({0,1});
dist[0] = 0;
while (!que.empty()) {
pair<int,int> x = que.top();
que.pop();
if(dist[x.second] < x.first) {
continue;
}
for(auto i:road[x.second]) {
if(dist[i.first] > x.first+i.second) {
dist[i.first] = x.first+i.second;
que.push({dist[i.first],i.first});
}
}
}
if(dist[N] <= K) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
ぷら