QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#223592#7615. Sequence Foldingucup-team266#WA 37ms7380kbC++142.2kb2023-10-22 13:43:302023-10-22 13:43:31

Judging History

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

  • [2023-10-22 13:43:31]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:7380kb
  • [2023-10-22 13:43:30]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int INF=1e18;
int n,m,tot;
vector <int> calc(vector <int> L,vector <int> R,vector <int> fr)
{
	sort(L.begin(),L.end()),sort(R.begin(),R.end());
	vector <int> vec;
	for(int i=0;i<L.size();i++)
	{
		int x=n-L[i]+1;
		int p=lower_bound(R.begin(),R.end(),x)-R.begin();
		if(p<R.size()&&R[p]==x) continue;
		int flg1=0,flg2=0;
		p=lower_bound(fr.begin(),fr.end(),x)-fr.begin();
		if(p<fr.size()&&fr[p]==x) flg1=1;
		p=lower_bound(fr.begin(),fr.end(),n-x+1)-fr.begin();
		if(p<fr.size()&&fr[p]==x) flg2=1;
		if(flg1&&flg2) vec.pb(L[i]);
		else if(flg1+flg2==0) tot++,vec.pb(L[i]);
		
	}
	for(int i=0;i<R.size();i++)
	{
		int x=n-R[i]+1;
		int p=lower_bound(L.begin(),L.end(),x)-L.begin();
		if(p<L.size()&&L[p]==x) continue;
		int flg1=0,flg2=0;
		p=lower_bound(fr.begin(),fr.end(),x)-fr.begin();
		if(p<fr.size()&&fr[p]==x) flg1=1;
		p=lower_bound(fr.begin(),fr.end(),n-x+1)-fr.begin();
		if(p<fr.size()&&fr[p]==x) flg2=1;
		
		if(flg1&&flg2) vec.pb(n-R[i]+1);
		else if(flg1+flg2==0) tot++,vec.pb(n-R[i]+1);
	}
	sort(vec.begin(),vec.end());
	return vec;
}
void solve()
{
	cin>>n>>m;
	vector <int> vec;
	while(m--)
	{
		int x;
		cin>>x;
		vec.pb(x);
	}
	vector <int> fr;
	while(n>1)
	{
		vector <int> L,R;
		for(int i=0;i<vec.size();i++) 
		{
			if(vec[i]<=n/2) L.pb(vec[i]);
			else R.pb(vec[i]);
		}
		fr=calc(L,R,fr);
		vec=L;
		n/=2;
	}
	cout<<tot<<"\n";
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 37ms
memory: 7380kb

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:

200552

result:

wrong answer 1st lines differ - expected: '99999', found: '200552'