QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#747930#7615. Sequence FoldinginksamuraiWA 0ms3500kbC++231.2kb2024-11-14 18:46:392024-11-14 18:46:40

Judging History

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

  • [2024-11-14 18:46:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-11-14 18:46:39]
  • 提交

answer

#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define vec(...) vector<__VA_ARGS__>
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

void slv(){
	int n,m;
	cin>>n>>m;

	map<int,int> mp;
	rep(i,m){
		int x;
		cin>>x;
		mp[x]=1;
	}
	int ans=0;
	while(n){
		map<int,int> ne_map;
		for(auto [x,c]:mp){
			int y=n-x+1;
			int rc=mp.find(y)==mp.end()?0:mp[y];
			if(c==rc){
				ne_map[x]=ne_map[y]=c;
			}else{
				int nec;
				if(c!=-1 and rc!=-1){
					ans+=1;
					nec=-1;
				}else if(c!=-1 or rc!=-1){
					nec=max(c,rc);
				}else{
					nec=-1;
				}
				ne_map[x]=ne_map[y]=nec;
			}
		}
		mp.swap(ne_map);
		// print(ans);
		// for(auto [x,c]:mp){
		// 	print(x,c);
		// }
		n/=2;
	}		
	print(ans);
}

signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int t;
	// cin>>t;
	t=1;
	rep(cs,t){
		slv();
	}
}

詳細信息

Test #1:

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

input:

8 3
1 5 8

output:

4 

result:

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