QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#402119 | #7615. Sequence Folding | Andeviking | WA | 88ms | 17668kb | C++20 | 1.4kb | 2024-04-29 22:06:21 | 2024-04-29 22:06:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define range(x) (x).begin(),(x).end()
const int dir[][2]={1,0,-1,0,0,1,0,-1};
void solve()
{
ll n,m;
cin>>n>>m;
set<ll>st;
for(int i=1;i<=m;++i){
ll x;
cin>>x;
st.insert(x);
}
ll len=n;
int ans=0;
set<ll>use;
while(len>1){
set<ll>now;
for(const auto& c:st){
if(st.count(len-c+1)){
if(use.count(c))
use.erase(c);
if(c<=len/2)
now.insert(c);
continue;
}
else{
if(use.count(c)){
use.erase(c);
continue;
}
ans++;
if(c<=len/2){
now.insert(c);
use.insert(c);
}
else{
now.insert(len-c+1);
use.insert(len-c+1);
}
}
}
st.swap(now);
now.clear();
len>>=1;
// cout<<ans<<'\n';
}
cout<<ans<<'\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
8 3 1 5 8
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 80ms
memory: 17668kb
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:
ok single line: '99999'
Test #4:
score: -100
Wrong Answer
time: 88ms
memory: 17616kb
input:
549755813888 100000 16886305 20807233 27844305 30727441 30898344 35755457 38085835 43336454 47877882 50347884 53237225 53718183 60030541 66954859 80773500 82511603 84025040 86398615 93070876 94502940 98906398 100677488 103720017 105522694 116741042 122492007 135222584 155167916 160926866 166110647 1...
output:
100001
result:
wrong answer 1st lines differ - expected: '100000', found: '100001'