QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#840216#1102. GuardRedDiamond#0 108ms3588kbC++171.5kb2025-01-02 16:21:252025-01-02 16:21:33

Judging History

This is the latest submission verdict.

  • [2025-01-02 16:21:33]
  • Judged
  • Verdict: 0
  • Time: 108ms
  • Memory: 3588kb
  • [2025-01-02 16:21:25]
  • Submitted

answer

#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

template<class T> bool ckmin(T& a, T b) { return b < a ? a = b, true : false; }
template<class T> bool ckmax(T& a, T b) { return a < b ? a = b, true : false; }

const int N = 1e5+7;

struct Ninja {
    int l, r, t;
};

bool operator < (Ninja a, Ninja b) { // mai vedem
    return a.r - a.l <= b.r - b.l;
}

Ninja a[N];
int one[N], zero[N];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, k, m; cin >> n >> k >> m;
    for (int i = 1; i <= m; ++i) cin >> a[i].l >> a[i].r >> a[i].t;
    
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector<int> pref(n + 1, 0);
        for (int i = 1; i <= n; ++i) {
            bool bit = !!(mask & (1 << (i - 1)));
            pref[i] = pref[i - 1] + bit;
        }
        bool ok = 1;
        for (int i = 1; i <= m; ++i) {
            ok &=  (pref[a[i].r] - pref[a[i].l - 1] == a[i].t);
        }
        if (ok == 1) {
            for (int i = 1; i <= n; ++i) {
                if (mask & (1 << (i - 1))) {
                    ++one[i];
                } else {
                    ++zero[i];
                }
            }
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (one[i] != 0 && zero[i] == 0) {
            cout << i << "\n";
            ++cnt;
        }
    }
    if (cnt == 0) cout << -1 << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 108ms
memory: 3588kb

input:

20 9 100
1 9 1
11 12 1
3 19 1
10 20 1
6 10 1
3 4 1
7 9 1
10 20 1
3 4 1
1 4 1
2 17 1
1 16 1
11 17 1
2 4 1
9 16 1
1 11 1
2 19 1
4 9 1
7 13 1
1 4 1
2 11 1
17 19 1
5 20 1
3 19 1
4 9 1
9 16 1
2 19 1
10 18 1
3 19 1
3 11 1
11 19 1
10 19 1
19 20 1
16 20 1
1 11 1
1 8 1
3 4 1
2 16 1
11 19 1
17 20 1
4 5 1
3 4 ...

output:

-1

result:

ok single line: '-1'

Test #2:

score: 0
Wrong Answer
time: 40ms
memory: 3580kb

input:

20 12 20
12 14 1
16 19 1
6 18 1
1 9 1
7 11 1
17 17 0
5 5 0
1 14 1
3 8 1
9 9 0
10 10 0
18 18 0
9 9 0
7 14 1
13 13 0
8 8 0
4 4 0
2 20 1
13 13 0
18 20 1

output:

-1

result:

wrong answer 1st lines differ - expected: '1', found: '-1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%