QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#136712#238. Distinct Values4k2kok#0 87ms6112kbC++201.4kb2023-08-09 10:21:362023-08-09 10:21:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-09 10:21:52]
  • 评测
  • 测评结果:0
  • 用时:87ms
  • 内存:6112kb
  • [2023-08-09 10:21:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mem(a,b) memset((a),(b),sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define db long double

const double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

int n, m;

struct node {
    int l, r;

    bool operator < (const node &n1) const {
        if (l == n1.l) return r > n1.r;
        return l < n1.l;
    }
};

vector<node> vv;

int ans[maxn];

void solve() {
    vv.clear();
    cin >> n >> m;
    for (int i = 1, l, r; i <= m; i++) {
        cin >> l >> r;
        vv.push_back({l, r});
    }
    sort(vv.begin(), vv.end());
    for (int i = 1; i <= n; i++) ans[i] = 1;
    int last = 0, nowl = 0;
    for (int i = 0; i < vv.size(); i++) {
        if (vv[i].r > last) {
            // cerr << last << ' ' << vv[i].l << ' ' << vv[i].r << '\n';
            nowl = max(last + 1, vv[i].l);
            last = vv[i].r;
            for (int j = nowl; j <= vv[i].r; j++) {
                ans[j] = j - nowl + 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

signed main(){
    io;
    int T = 1;
    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 87ms
memory: 6112kb

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 '