QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#460438 | #7615. Sequence Folding | Alish | WA | 152ms | 16048kb | C++17 | 1.4kb | 2024-07-01 16:42:01 | 2024-07-01 16:42:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define Mp make_pair
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("tests.in" , "r" , stdin) ;
ll mod = 1e9+7;
map<ll, int> mp;
ll n, m, ans;
int main()
{
fast_io
cin>>n>>m;
for (int i=0; i<m; i++){
ll x; cin>>x;
mp[x]=1;
}
while(n!=1){
for (auto &pp: mp){
if(pp.F<=n/2){
if(mp[n-pp.F+1]!=pp.S && (pp.S==2 || mp[n-pp.F+1]==2)) pp.S=min(pp.S, mp[n-pp.F+1]);
if(mp[n-pp.F+1]!=pp.S && !(pp.S==2 || mp[n-pp.F+1]==2)){pp.S=2; ans++;}
}
else{
if(mp.count(n-pp.F+1))continue;
if(pp.S!=2){
mp[n-pp.F+1]=2;
ans++;
}
}
}
while(1){
if(mp.empty()) break;
auto x=mp.end(); x--;
if((x->F)>n/2) mp.erase(x);
else break;
}
n>>=1;
}
cout<<ans<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 152ms
memory: 16048kb
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:
198516
result:
wrong answer 1st lines differ - expected: '99999', found: '198516'