제출 #1297111

#제출 시각아이디문제언어결과실행 시간메모리
1297111nguyhoangphuRMQ (NOI17_rmq)C++20
23 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define file "a" // #define int long long #define ll long long #define pii pair<int, int> #define pli pair<ll, int> #define fi first #define se second #define sz(a) (int)a.size() #define pb push_back #define mask(i) (1 << i) const int N = 1e6, inf = 1e9; mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); int rad(int l, int r) { return l + rd() % (r - l + 1); } void MAX(int &a, int b) { a = max(a, b); } void MIN(int &a, int b) { a = min(a, b); } struct stt { int l, r, id; bool operator < (const stt &o) const { return id > o.id; } }; int n, q; int kq[N + 2]; bool vis[N + 2]; stt a[N + 2]; int x[15], mn[15][15]; bool kt[15], ok, run; vector<pii> g[15]; void track(int i) { if (ok) return; if (i == n) { ok = 1; for (int j = 0; j < n; j++) cout << x[j] << " "; return; } for (int j = 0; j < n; j++) if (!kt[j]) { kt[j] = 1; x[i] = j; mn[i][i] = j; for (int p = i - 1; p >= 0; p--) mn[p][i] = min(mn[p][i - 1], j); run = 1; for (pii x : g[i]) { int l = x.fi, val = x.se; if (mn[l][i] != val) { run = 0; break; } } if (run) track(i + 1); kt[j] = 0; } } void Sub1() { for (int i = 1; i <= q; i++) g[a[i].r].pb({a[i].l, a[i].id}); track(0); if (!ok) for (int i = 0; i < n; i++) cout << -1 << " "; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(file".inp", "r")) { freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } cin >> n >> q; for (int i = 1; i <= q; i++) cin >> a[i].l >> a[i].r >> a[i].id; sort(a + 1, a + q + 1); if (max(n, q) <= 10) return Sub1(), 0; }

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

rmq.cpp: In function 'int main()':
rmq.cpp:72:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |     freopen(file".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
rmq.cpp:73:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |     freopen(file".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...