QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748622#7615. Sequence Foldingxh_team#WA 0ms3548kbC++201.3kb2024-11-14 20:53:432024-11-14 20:53:44

Judging History

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

  • [2024-11-14 20:53:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-11-14 20:53:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
#define PII pair<int,int>
#define lowbit(x) x&-x
//#define endl "\n"
#define lson 2*p
#define rson 2*p+1
const int N=5e5+10;
const int mod=1e9+7;
map<int,int> mp;
int a[N];
void solve() {
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++) {
		cin>>a[i];
		mp[a[i]]=2;
	}
	for(int i=1;i<=m;i++) {
		int j=n-a[i]+1;
		if(mp[j]!=2) mp[j]=1;
	}
	//mp=1 为0
	//mp=2 为1
	//mp=3 自适应
	int ans=0;
	while(n>1) {
        vector<int> aa;
        for (auto [x, y] : mp) {
            if (mp.count(n - x + 1)) {
                aa.push_back(n - x + 1);
            }
        }
        for (int x : aa) {
            mp[x] = 1;
        }
		for(auto [x,y]:mp) {
			if(x>n/2) break;
			int p=n-x+1;
			//cout<<x<<" "<<p<<" "<<mp[x]<<" "<<mp[p]<<endl;
			if(mp[p]==mp[x]) {
				continue;
			} else {
				if(mp[p]==3) {
					continue;
				}
				if(y==3) {
					mp[x]=mp[p];
					continue;
				}
				mp[x]=3;
				ans++;
			}
		}
        mp.erase(mp.find(n / 2 + 1), mp.end());
		n>>=1;
	}
	cout<<ans<<'\n';
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T=1;
	// cin>>T;
	while(T--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3548kb

input:

8 3
1 5 8

output:

1

result:

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