QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#278049#7615. Sequence Foldingucup-team958#WA 581ms145020kbC++20887b2023-12-07 11:12:422023-12-07 11:12:42

Judging History

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

  • [2023-12-07 11:12:42]
  • 评测
  • 测评结果:WA
  • 用时:581ms
  • 内存:145020kb
  • [2023-12-07 11:12:42]
  • 提交

answer

#include<bits/stdc++.h>
#define mp make_pair
#define ll long long
#define il inline
using namespace std;
const int maxn=10000010;
il ll read(){
	ll x=0;
	char c=getchar();
	for(;!(c>='0'&&c<='9');c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+c-'0';
	return x;
}
ll n,m,ans;
map<ll,int>a;
ll st[maxn];
void calc(ll l,ll r){
	if(l==r){
		ans+=(a[l]==-1);
		return ;
	}
	ll mid=l+r>>1,top=0;
	for(auto it=a.lower_bound(l);it!=a.end();it++) 
		if(it->first>r) break;
		else st[++top]=it->first;
	for(int i=1;i<=top;i++){
		ll x=st[i],y=mid*2-x+1;
		ll w1=a[x],w2=a[y];
		if(w1==-1&&w2==-1) ans++;
		else if(w1==-1) a[x]=w2,ans++;
		else if(w2==-1) a[y]=w1,ans++;
		else if(w1!=w2) a[x]=a[y]=-1;
	}
	calc(l,mid);
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=m;i++) a[read()]=1;
	calc(1,n);
	printf("%lld\n",ans);
	return 0;
}

详细

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 482ms
memory: 113960kb

input:

17179869184 100000
138476 774165 993977 1152277 1236393 1244970 1534017 1693701 1763926 1778781 1842066 1874644 1885666 2120429 2485344 2977941 3158255 3340476 3504862 4000117 4066652 4197639 4338723 4389163 4576965 4761601 5097091 5175412 5295902 5810551 5855982 6001770 6111262 6163309 6351547 6582...

output:

99999

result:

ok single line: '99999'

Test #4:

score: -100
Wrong Answer
time: 581ms
memory: 145020kb

input:

549755813888 100000
16886305 20807233 27844305 30727441 30898344 35755457 38085835 43336454 47877882 50347884 53237225 53718183 60030541 66954859 80773500 82511603 84025040 86398615 93070876 94502940 98906398 100677488 103720017 105522694 116741042 122492007 135222584 155167916 160926866 166110647 1...

output:

100001

result:

wrong answer 1st lines differ - expected: '100000', found: '100001'