QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#647576#4883. Bayan Testingship2077WA 17ms3816kbC++23823b2024-10-17 14:46:592024-10-17 14:47:00

Judging History

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

  • [2024-10-17 14:47:00]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3816kb
  • [2024-10-17 14:46:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=2e5+5,inf=1e9;
int n,m,num,cur,ans[M];
struct info{ int l,r;
    bool operator <(const info &a) const
        {return r==a.r?l<a.l:r<a.r;}
}a[M];
int read(){
    int x=0;char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
    return x;
}
void solve(){
    n=read();m=read();num=0;
    for (int i=1;i<=m<<1;i++){
        int l=read(),r=read();
        if (l<r) a[++num]={l,r};
    }
    if (num<m) return puts("-1"),void();
    sort(a+1,a+num+1);
    for (int i=1;i<=n;i++) ans[i]=i;
    ans[a[num-m+1].l]=inf;
    for (int i=a[num-m+1].r;i<=n;i++) ans[i]=inf;
    for (int i=1;i<=n;i++) printf("%d%c",ans[i]," \n"[i==n]);
}
int main(){int T=read();while (T--) solve();return 0;}

详细

Test #1:

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

input:

3
2 1
1 1
2 2
6 2
1 3
4 6
2 4
3 5
4 3
1 2
1 1
2 2
2 3
3 3
3 4

output:

-1
1 2 1000000000 4 1000000000 1000000000
1000000000 1000000000 1000000000 1000000000

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 10ms
memory: 3792kb

input:

100000
2 1
1 1
2 2
2 1
2 2
1 2
2 1
1 2
2 2
2 1
1 2
2 2
2 1
2 2
1 2
2 1
2 2
1 1
2 1
1 1
2 2
2 1
1 2
2 2
2 1
2 2
1 1
2 1
2 2
1 2
2 1
2 2
1 1
2 1
2 2
1 2
2 1
2 2
1 2
2 1
2 2
1 1
2 1
2 2
1 1
2 1
1 2
2 2
2 1
2 2
1 2
2 1
2 2
1 2
2 1
2 2
1 2
2 1
1 1
2 2
2 1
2 2
1 2
2 1
1 1
2 2
2 1
1 1
2 2
2 1
2 2
1 2
2 1
2...

output:

-1
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
-1
-1
1000000000 1000000000
-1
1000000000 1000000000
-1
1000000000 1000000000
1000000000 1000000000
-1
-1
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
-1
1000000000 1...

result:

ok ok (100000 test cases)

Test #3:

score: -100
Wrong Answer
time: 17ms
memory: 3816kb

input:

25000
10 5
4 10
1 4
9 9
2 9
5 8
1 8
1 5
5 5
4 9
6 6
11 5
9 11
4 7
2 2
2 5
8 10
3 11
2 4
4 8
3 10
4 6
5 2
1 3
4 4
1 5
5 5
6 3
4 6
3 3
1 5
3 6
1 1
1 3
7 3
4 4
3 5
1 6
3 4
2 3
1 2
7 3
3 4
1 5
6 7
2 6
3 5
2 3
5 2
5 5
4 5
2 3
1 1
10 5
3 6
4 5
3 3
6 9
2 5
9 10
5 6
5 7
1 4
8 9
11 5
1 10
2 11
6 9
2 6
6 6
8 ...

output:

1000000000 2 3 4 5 6 7 1000000000 1000000000 1000000000
1 2 3 1000000000 5 6 7 1000000000 1000000000 1000000000 1000000000
1000000000 2 1000000000 1000000000 1000000000
1000000000 2 3 4 1000000000 1000000000
1 2 1000000000 1000000000 1000000000 1000000000 1000000000
1 2 1000000000 4 1000000000 10000...

result:

wrong answer the number of segments with two equal elements is 4 != 5 (test case 1)