QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#514482#1173. Knowledge Is...wyhaoWA 1ms5996kbC++14939b2024-08-11 02:03:482024-08-11 02:03:48

Judging History

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

  • [2024-08-11 02:03:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5996kb
  • [2024-08-11 02:03:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,m;
struct node{
    int x,y,id;
}p[N];
bool cmp1(node x,node y){
    if(x.y == y.y) return x.x<y.x;
    return x.y<y.y;
}
bool cmp2(node x,node y){
    return x.x<y.x;
}
int ans[N];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    sort(p+1,p+n+1,cmp1);
    sort(p+m+1,p+n+1,cmp2);
    int j=m+1;
    for(int i=1;i<=m;i++){
        while(j<=n and p[j].x<=p[i].y) j++;
        if(j>n) break;
        // printf("%d %d %d\n",j,p[j].x,p[i].y);
        ans[p[j].id] = i;
        j++;
    }
    for(int i=1;i<=m;i++) ans[p[i].id] = i;
    for(int i=1;i<=n;i++){
        printf("%d ",ans[i]);
    }
    return 0;
}
/*
7 5
9 10
7 9
3 4
9 10
2 6
8 9
5 8

2 2
1 2
3 4

2 1
1 2
2 3

10 2
1 2
1 2 
1 2
2 3
2 4
3 4
3 4
1 4
3 4
2 3
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3960kb

input:

7 5
9 10
7 9
3 4
9 10
2 6
8 9
5 8

output:

1 4 1 2 2 5 3 

result:

ok answer = 7

Test #2:

score: 0
Accepted
time: 1ms
memory: 5924kb

input:

2 2
1 2
3 4

output:

1 2 

result:

ok answer = 2

Test #3:

score: 0
Accepted
time: 1ms
memory: 5996kb

input:

2 1
1 2
2 3

output:

1 0 

result:

ok answer = 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 5932kb

input:

1 1
4 26

output:

1 

result:

ok answer = 1

Test #5:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

500 258
1 3
3 5
2 4
3 5
4 5
4 5
1 4
1 2
3 5
2 5
2 5
4 5
4 5
4 5
2 3
1 4
1 4
1 4
4 5
4 5
2 3
4 5
3 5
3 5
1 5
1 4
2 5
1 5
3 5
3 4
4 5
2 3
3 5
3 5
4 5
2 3
1 5
1 5
2 3
2 3
3 4
3 5
3 4
1 3
1 2
1 5
4 5
2 3
2 4
1 3
4 5
4 5
4 5
1 3
3 5
4 5
3 5
1 5
1 2
1 2
3 5
3 5
4 5
3 4
3 5
2 3
2 5
2 4
2 5
3 5
2 3
1 5
4 5
...

output:

70 9 190 0 101 100 123 27 0 0 0 0 0 0 115 131 132 133 0 0 93 0 0 0 0 120 0 0 0 215 0 94 0 0 0 96 0 0 100 101 221 0 224 66 18 257 0 104 183 56 0 0 0 42 0 0 0 0 16 13 15 14 117 230 13 92 0 178 0 11 97 0 97 180 181 40 111 200 0 110 108 142 32 23 30 116 10 203 204 83 0 185 207 93 0 199 193 0 198 92 6 33...

result:

ok answer = 376

Test #6:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

500 242
8 9
9 10
2 9
8 10
9 10
6 10
4 8
4 5
2 6
7 10
3 8
1 8
1 6
5 9
7 8
8 10
8 9
8 10
2 9
2 3
6 8
3 10
5 9
1 3
6 8
4 10
9 10
8 9
8 10
1 9
3 9
3 7
2 3
6 10
3 6
6 10
3 4
3 6
9 10
5 7
8 10
6 10
5 6
5 7
7 8
1 3
4 7
9 10
4 9
2 4
8 9
1 3
8 10
3 4
9 10
4 9
5 10
8 9
1 3
1 5
8 10
3 4
8 9
3 9
3 6
3 10
6 7
7 ...

output:

157 206 0 123 215 50 185 66 91 102 180 170 75 31 234 134 150 136 0 19 207 1 32 9 201 10 192 156 112 238 0 133 16 55 99 54 39 97 184 151 110 47 108 150 223 7 143 209 6 27 165 6 118 38 199 13 25 152 5 45 127 36 164 0 98 0 165 219 240 204 92 89 16 88 138 205 208 179 129 4 226 232 207 186 208 131 121 82...

result:

ok answer = 471

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3964kb

input:

500 250
50 84
36 68
94 98
13 88
4 62
45 74
80 89
56 87
65 89
44 52
69 78
29 76
61 90
91 99
16 98
69 92
50 77
86 95
73 79
83 90
78 89
1 79
81 86
14 37
91 94
27 48
11 73
94 97
49 80
15 60
26 39
34 76
69 77
22 72
6 78
92 96
46 83
83 94
62 95
77 80
32 72
46 90
41 88
47 91
68 75
14 36
26 43
14 87
49 74
2...

output:

53 155 202 0 118 196 141 68 97 84 224 206 81 184 0 103 216 168 235 151 128 227 144 35 186 63 189 205 240 109 41 208 219 180 220 191 44 154 85 242 182 45 37 47 205 33 52 0 197 40 50 139 127 106 95 79 204 86 224 133 39 115 133 5 212 51 177 138 178 16 117 48 196 202 32 167 10 193 137 65 150 23 147 107 ...

result:

wrong answer participant answer = 479, judge answer = 500