QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748377#7615. Sequence Foldingxh_team#TL 0ms3628kbC++231011b2024-11-14 20:13:312024-11-14 20:13:31

Judging History

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

  • [2024-11-14 20:13:31]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3628kb
  • [2024-11-14 20:13:31]
  • 提交

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;
	}
	//mp=1 为0
	//mp=2 为1
	//mp=3 自适应
	int ans=0;
	while(n>1) {
		for(auto [x,y]:mp) {
			if(x>n) break;
			// if(x>n/2) continue;
			int p=n-x+1;
			// cout<<x<<" "<<p<<endl;
			if(mp[p]==y) {
				continue;
			} else {
				if(mp[p]==3) {
					continue;
				}
				if(y==3) {
					mp[x]=mp[p];
					continue;
				}
				mp[x]=3;
				// cout<<n<<endl;
				ans++;
			}
		}
		for(auto [x,y]:mp) if(x>n/2) mp[x]=0;
		n>>=1;
		// cout<<endl;
	}
	cout<<ans<<endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T=1;
	// cin>>T;
	while(T--) {
		solve();
	}
}

詳細信息

Test #1:

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

input:

8 3
1 5 8

output:

2

result:

ok single line: '2'

Test #2:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Time Limit Exceeded

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: