QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#44081#238. Distinct ValuesTenebrisWA 114ms4036kbC++986b2022-08-12 19:07:312022-08-12 19:07:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-12 19:07:33]
  • 评测
  • 测评结果:WA
  • 用时:114ms
  • 内存:4036kb
  • [2022-08-12 19:07:31]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int T;
    cin >> T;

    while (T--) {
        int N, Q;
        cin >> N >> Q;
        vector<int> seg_end(N + 1, 0);
        vector<bool> reset(N + 1, true);

        for (int i = 0; i < Q; i++) {
            int s, e;
            cin >> s >> e;
            seg_end[s] = max(seg_end[s], e);
        }

        int end = 0;
        int prev = -1;

        for (int i = 1; i <= N; i++) {
            if (seg_end[i] <= end)
                continue;

            for (int j = max(i + 1, end + 2); j <= seg_end[i]; j++)
                reset[j] = false;

            end = seg_end[i];
        }

        int combo = 1;
        for (int i = 1; i <= N; i++) {
            if (reset[i])
                combo = 1;

            cout << combo << ' ';
            combo++;
        }
        cout << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 114ms
memory: 4036kb

input:

11116
10 2
5 5
5 6
10 1
7 10
10 1
2 6
10 1
2 5
10 1
6 7
10 2
8 9
7 10
10 2
1 4
6 10
10 4
8 8
10 10
3 6
1 5
10 3
8 8
10 10
8 10
10 4
6 10
1 5
2 6
1 2
10 3
4 4
4 8
4 8
10 4
1 5
1 2
5 5
2 4
10 4
2 5
9 10
6 7
2 4
10 1
5 6
10 4
10 10
8 10
2 5
10 10
10 1
1 2
10 4
7 8
5 6
7 9
10 10
10 4
3 7
6 6
8 10
3 4
10...

output:

1 1 1 1 1 2 1 1 1 1 
1 1 1 1 1 1 1 2 3 4 
1 1 2 3 4 5 1 1 1 1 
1 1 2 3 4 1 1 1 1 1 
1 1 1 1 1 1 2 1 1 1 
1 1 1 1 1 1 1 2 3 4 
1 2 3 4 1 1 2 3 4 5 
1 2 3 4 5 1 1 1 1 1 
1 1 1 1 1 1 1 1 2 3 
1 2 3 4 5 1 1 2 3 4 
1 1 1 1 2 3 4 5 1 1 
1 2 3 4 5 1 1 1 1 1 
1 1 2 3 4 1 2 1 1 2 
1 1 1 1 1 2 1 1 1 1 
1 1 2 ...

result:

wrong answer 10th lines differ - expected: '1 2 3 4 5 1 2 3 4 5', found: '1 2 3 4 5 1 1 2 3 4 '