QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#748616 | #7615. Sequence Folding | xh_team# | WA | 152ms | 31208kb | C++23 | 1.2kb | 2024-11-14 20:52:19 | 2024-11-14 20:52:20 |
Judging History
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) {
map<int,int> mp1;
for(auto [x,y]:mp1) {
int p=n-x+1;
if(!mp[p]) mp[p]=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++;
}
}
mp1=mp;
for(auto [x,y]:mp1) if(x>n/2) mp.erase(mp.find(x));
mp1.clear();
n>>=1;
}
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: 3596kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 152ms
memory: 31208kb
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:
99998
result:
wrong answer 1st lines differ - expected: '99999', found: '99998'