이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 10000000000000000
using namespace std;
vector<pair<long long , long long> >gr[2000000];
long long dist[2000000] , vis[2000000];
priority_queue<pair<long long , long long> >q;
vector<vector<long long> >edge;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long menge , numm , nummer , que , cmp , bi;
cin >> menge >> que;
for(long long i = 0 ; i < menge; i++){
gr[i].push_back({i + 1 , 1});
gr[i + 1].push_back({i , 0});
edge.push_back({i , i + 1 , 1});
edge.push_back({i + 1, i , 0});
}
while(que--){
cin >> numm >> nummer >> cmp >> bi;
// numm++;
nummer++;
if(bi == 0){
cmp = nummer - numm - cmp;
gr[numm].push_back({nummer , cmp});
edge.push_back({numm , nummer , cmp});
}
else{
cmp = nummer - numm - cmp + 1;
cmp *= -1;
gr[nummer].push_back({numm , cmp});
edge.push_back({nummer , numm , cmp});
}
}
for(long long i = 0 ; i < 2000000 ; i++){
dist[i] = inf;
}
dist[0] = 0;
for(long long k = 0 ; k < menge * 2 ; k++){
for(long long i = 0 ; i < edge.size() ; i++){
if(dist[edge[i][0]] != inf && dist[edge[i][0]] + edge[i][2] < dist[edge[i][1]]){
dist[edge[i][1]] = dist[edge[i][0]] + edge[i][2];
}
}
}
for(long long i = 0 ; i < edge.size() ; i++){
if(dist[edge[i][0]] != inf && dist[edge[i][0]] + edge[i][2] < dist[edge[i][1]]){
cout << -1 << "\n";
return 0;
}
}
for(long long i = 0 ; i < menge ; i++){
// cout << dist[i] << "\n";
if(dist[i] == dist[i + 1]){
cout << 0;
}
else{
cout << 1;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
restore.cpp: In function 'int main()':
restore.cpp:44:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(long long i = 0 ; i < edge.size() ; i++){
| ~~^~~~~~~~~~~~~
restore.cpp:50:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(long long i = 0 ; i < edge.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... |