이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define A first
#define B second
#define MP make_pair
#define ms(a, x) memset(a, x, sizeof(a))
#define boost() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pld;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const int mxN=5e3+5;
vector <vector<int>> adj(mxN);
int dp[mxN][2];
void bfs(int node){
queue <int> q;
q.push(node);
dp[node][0]=0;
while(!q.empty()){
int u = q.front();
q.pop();
for(auto x:adj[u]){
if(dp[u][0]+1 < dp[x][1]){
dp[x][1] = dp[u][0]+1;
q.push(x);
}
}
for(auto x:adj[u]){
if(dp[u][1]+1 < dp[x][0]){
dp[x][0] = dp[u][1]+1;
q.push(x);
}
}
}
}
int main(){
int n, m, k;
cin >> n >> m >> k;
for(int i=0; i<m; i++){
int x, y;
cin >> x >> y;
adj[x].push_back(y);
adj[y].push_back(x);
}
vector <pair<pii, pii>> v;
for(int i=0; i<k; i++){
int x, y, d;
cin >> x >> y >> d;
v.push_back({{x, y}, {d, i}});
}
sort(v.begin(), v.end());
vector <int> ans(k);
int cur=-1;
for(int i=0; i<v.size(); i++){
if(v[i].A.A != cur){
ms(dp, INF);
cur=v[i].A.A;
bfs(cur);
}
ans[v[i].B.B] = (dp[v[i].A.B][(v[i].B.A % 2)] <= v[i].B.A ? 1:0);
}
for(int i=0; i<k; i++)
cout << (ans[i] == 1 ? "TAK":"NIE") << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
mor.cpp: In function 'int main()':
mor.cpp:67:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i=0; i<v.size(); i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |