이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 5505;
const int MAXN = (int) 5e3 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
vector<pair<int, pii>> ed;
int d[MAXN];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
#ifdef Local
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
#endif
cin>>n>>m;
memset(d, 0x7f, sizeof(d));
for(int i = 0; i < m; i++){
int l, r, k, val;
cin>>l>>r>>k>>val;
l++;r++;
if(val == 0){
ed.push_back({-k, {r, l - 1}});
}else{
ed.push_back({k - 1, {l - 1, r}});
}
}
for(int i = 0; i < n; i++){
ed.push_back({0, {i + 1, i}});
ed.push_back({1, {i, i + 1}});
}
d[0] = 0;
bool done;
for(int i = 0; i <= n; i++){
done = 0;
for(auto j: ed){
if(d[j.ss.ff] < mod){
if(d[j.ss.ss] > d[j.ss.ff] + j.ff){
done = 1;
d[j.ss.ss] = d[j.ss.ff] + j.ff;
}
}
}
}
if(done){
cout<<-1<<endl;
return 0;
}
for(int i = 0; i < n; i++){
cout<<((d[i + 1] - d[i]) ^ 1)<<" ";
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
컴파일 시 표준 에러 (stderr) 메시지
restore.cpp: In function 'int main()':
restore.cpp:59:5: warning: 'done' may be used uninitialized in this function [-Wmaybe-uninitialized]
59 | if(done){
| ^~
# | 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... |