Submission #1297107

#TimeUsernameProblemLanguageResultExecution timeMemory
1297107tink8_triRMQ (NOI17_rmq)C++17
0 / 100
17 ms428 KiB
#include <bits/stdc++.h>

#define int long long
#define pii pair < int, int >
#define fi first
#define se second
const int inf = 1e18;
const int maxn = 1e6 + 5;
const int offset = 1e6;
using namespace std;

#define mask(x) (1ll << x)

int n, m;

struct {
    int l, r, w;
} Q[maxn];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #define NAME "test"
    if (fopen(NAME".INP","r")) {
        freopen(NAME".INP","r",stdin);
        freopen(NAME".OUT","w",stdout);
    } 
    
    int m;

    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        cin >> Q[i].l >> Q[i].r >> Q[i].w;
    }

    if (max(n, m) > 10) {
        for (int i = 1; i <= n; i++) cout << -1;
        return 0;
    }

    vector < int > v;

    for (int i = 0; i < n; i++) {
        v.push_back(i);
    }

    do {
        bool ok = true;
        for (int i = 1; i <= m; i++) {
            int l = Q[i].l;
            int r = Q[i].r;

            int mn = v[l];

            for (int j = l; j <= r; j++) {
                mn = min(mn, v[j]);
            }

            if (mn != Q[i].w) {
                ok = false;
                break;
            }
        }

        if (ok) {
            for (int x : v) cout << x << ' ';
            return 0;
        }
    } while (next_permutation(v.begin(), v.end()));
    for (int i = 1; i <= n; i++) cout << -1;
}   



Compilation message (stderr)

rmq.cpp: In function 'int main()':
rmq.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen(NAME".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
rmq.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(NAME".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...