QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711718#4393. Snatch Grocerieshejinming983282#WA 31ms5900kbC++231.4kb2024-11-05 13:10:052024-11-05 13:10:06

Judging History

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

  • [2024-11-05 13:10:06]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:5900kb
  • [2024-11-05 13:10:05]
  • 提交

answer

// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);

using namespace std;
inline int read() {
    int now = 0, nev = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
    return now * nev;
}
void write(int x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
struct node {
    int e, l, qs;
};
bool cmp(node w, node s) {
    if(w.e == s.e) {
        if(w.l == s.l) return w.qs < s.qs;
        return w.l > s.l;
    }
    return w.e < s.e;
}
signed main() {
    quickio
    quickin
    quickout
    int T = read();
    while(T--) {
        int n = read();
        vector <node> q(n);
        for(int i = 0; i < n; i++)
            q[i].e = read(), q[i].l = read(), q[i].qs = i;
        sort(q.begin(), q.end(), cmp);
        int sum = 0, f = 0;
        for(int i = 0; i < n; i++) {
            if(q[i + 1].e <= q[i].l && i < n)
                { f = 1; break ; }
            if(!f) sum++;
        }
        if(n == 1) sum = 1;
        write(sum), putchar(10);
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 31ms
memory: 5900kb

input:

5
3
1 2
3 4
5 6
3
1 2
3 4
4 5
100000
263324740 263324748
920719069 920719077
82595123 82595132
765796214 765796222
621714954 621714959
77799324 77799332
278166427 278166428
375391536 375391545
856576804 856576812
512542774 512542781
829984452 829984457
302442403 302442404
779239984 779239986
1189173...

output:

3
1
275
5575
9999

result:

wrong answer 5th lines differ - expected: '10000', found: '9999'