제출 #568106

#제출 시각아이디문제언어결과실행 시간메모리
568106lacitoRestore Array (RMI19_restore)C++14
100 / 100
325 ms1380 KiB
#pragma GCC optimize ("Ofast") #pragma GCC target ("avx,avx2,fma") #include "bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; #define int long long #define endl '\n' #define mod 1000000007 //\ #define mod 1686876991 const int maxn = 1000001; const int INF = 1e8; int dist[maxn]; vector<array<int, 3>> E; signed main () { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 0 ; i < m ; i++) { int x, y, k, v; cin >> x >> y >> k >> v; x++,y++; int s = y - x + 1; if (v == 1) { k--; E.push_back({y, x - 1, k - s}); //cerr << y << " " << x - 1 << " " << k - s << endl; } else { E.push_back({x - 1, y, s - k}); //cerr << x - 1 << " " << y << " " << s - k << endl; } } for (int i = 1 ; i <= n ; i++) dist[i] = INF; for (int i = 0 ; i < n ; i++) { E.push_back({i, i + 1, 1}); E.push_back({i + 1, i, 0}); //cerr << i << " " << i + 1 << " " << 1 << endl; //cerr << i + 1 << " " << i << " " << 0 << endl; } for (int iter = 0 ; iter < n ; iter++) { // for (int i = 0 ; i <= n ; i++) { // cerr << dist[i] << " "; // } // cerr << endl; for (auto [u,v,w] : E) { if (dist[u] != INF) dist[v] = min(dist[v], dist[u] + w); } } bool imp = 0; for (auto [u,v,w] : E) { if (dist[v] != INF && dist[u] != INF && dist[v] > dist[u] + w) imp = 1; } // for (int i = 0 ; i <= n ; i++) { // cerr << dist[i] << " "; // } if (imp) cout << -1; else { for (int i = 1 ; i <= n ; i++) { cout << (dist[i] > dist[i-1]) << " "; } } }

컴파일 시 표준 에러 (stderr) 메시지

restore.cpp:17:1: warning: multi-line comment [-Wcomment]
   17 | //\
      | ^
restore.cpp: In function 'int main()':
restore.cpp:63:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   63 |         for (auto [u,v,w] : E) {
      |                   ^
restore.cpp:71:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   71 |     for (auto [u,v,w] : E) {
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...