QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#454088 | #8528. Chords | ucup-team1525# | WA | 2676ms | 6104kb | C++20 | 1.8kb | 2024-06-24 16:27:18 | 2024-06-24 16:27:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
mt19937 rnd(time(0));
struct dt
{
int l,r,len,v;
bool operator<(const dt &a)const
{
return (len==a.len?l<a.l:len<a.len);
}
}a[N];
int f[N*2];
int n;
inline void ins(int x,int y)
{
for (;x<=n*2;x+=x&(-x))
f[x]^=y;
}
inline int ask(int x)
{
int ans=0;
for (;x;x-=x&(-x))
ans^=f[x];
return ans;
}
int g[N],h[N];
void raodong()
{
for (int i=1;i<=30;++i)
{
g[i]=rnd()%max(n/3,1)+1;
int q=min(n-g[i]+1,15);
h[i]=g[i]+rnd()%q;
// h[i]=rnd()%n+1;
// while (g[i]==h[i])
// {
// h[i]=rnd()%n+1;
// }
swap(a[g[i]],a[h[i]]);
}
}
void roll_back()
{
for (int i=30;i;--i)
{
swap(a[g[i]],a[h[i]]);
}
}
int main()
{
clock_t bg=clock();
scanf("%d",&n);
for (int i=1;i<=n;++i)
{
scanf("%d%d",&a[i].l,&a[i].r);
a[i].len=a[i].r-a[i].l;
a[i].len=min(a[i].len,n*2-a[i].len);
a[i].v=rnd();
// a[i+n]={a[i].r,a[i].l,n*2-a[i].len};
}
sort(a+1,a+1+n);
int ans=0;
while (clock()-bg<=2.9*CLOCKS_PER_SEC)
// for (int t=1;t<=100;++t)
{
int sum=0;
for (int i=1;i<=n;++i)
if (ask(a[i].l-1)==ask(a[i].r))
{
++sum;
ins(a[i].l,a[i].v);
ins(a[i].r,a[i].v);
}
if (sum>ans)
{
ans=sum;
}
else
{
if (sum<ans)
roll_back();
}
if (n==1)
break;
raodong();
for (int i=1;i<=2*n;++i)
f[i]=0;
}
printf("%d\n",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2358ms
memory: 3980kb
input:
5 1 2 4 10 7 9 3 5 6 8
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
1 1 2
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2245ms
memory: 3860kb
input:
2 1 3 2 4
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 2237ms
memory: 3992kb
input:
2 1 4 2 3
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 2297ms
memory: 4060kb
input:
3 3 5 1 4 2 6
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 2353ms
memory: 3916kb
input:
4 2 7 1 6 3 8 4 5
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 2397ms
memory: 4060kb
input:
6 8 9 6 7 4 10 1 5 11 12 2 3
output:
5
result:
ok 1 number(s): "5"
Test #8:
score: 0
Accepted
time: 2361ms
memory: 5932kb
input:
9 2 8 10 17 9 15 1 12 6 14 3 13 4 11 5 7 16 18
output:
4
result:
ok 1 number(s): "4"
Test #9:
score: 0
Accepted
time: 2500ms
memory: 3860kb
input:
13 8 16 2 13 14 23 10 11 7 17 6 24 12 18 9 20 4 15 19 21 3 26 1 25 5 22
output:
6
result:
ok 1 number(s): "6"
Test #10:
score: 0
Accepted
time: 2624ms
memory: 6104kb
input:
19 34 35 4 20 9 31 12 17 18 38 23 29 19 30 25 26 10 36 1 7 13 37 2 11 8 32 6 28 16 24 5 27 14 21 15 22 3 33
output:
8
result:
ok 1 number(s): "8"
Test #11:
score: 0
Accepted
time: 2572ms
memory: 5900kb
input:
28 9 45 7 19 15 40 42 44 26 31 20 22 16 55 6 34 41 56 28 51 2 33 36 53 3 13 37 52 4 46 12 48 21 27 24 30 23 38 1 32 8 14 43 54 11 17 47 49 29 35 5 25 18 39 10 50
output:
10
result:
ok 1 number(s): "10"
Test #12:
score: 0
Accepted
time: 2672ms
memory: 4052kb
input:
42 2 66 29 75 5 45 8 53 50 72 25 44 15 47 6 57 64 68 26 80 32 49 65 70 27 54 37 58 18 36 10 48 3 63 28 60 30 76 16 41 7 83 21 24 14 17 31 67 62 71 20 74 11 33 43 84 40 61 19 69 35 82 13 42 34 79 12 73 9 51 4 23 77 81 22 59 1 52 39 55 38 56 46 78
output:
11
result:
ok 1 number(s): "11"
Test #13:
score: -100
Wrong Answer
time: 2676ms
memory: 4044kb
input:
63 40 105 6 104 45 83 16 22 31 34 51 57 64 92 75 112 70 82 65 121 32 93 18 60 30 68 72 77 86 101 10 47 85 94 36 71 11 35 27 126 56 74 15 52 19 91 88 110 76 97 25 33 58 109 42 54 12 26 73 107 99 118 29 106 44 90 3 9 23 122 14 79 87 116 4 81 17 111 41 53 50 123 38 124 13 114 67 96 5 100 55 115 43 62 4...
output:
16
result:
wrong answer 1st numbers differ - expected: '17', found: '16'