QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#424495 | #2960. Social Distancing | TheSleepyDevil# | WA | 1ms | 3616kb | C++20 | 1.9kb | 2024-05-29 11:22:49 | 2024-05-29 11:22:51 |
Judging History
answer
/*
Hell, 'til I reach Hell, I ain't scared
Mama checkin' in my bedroom, I ain't there
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Major ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TxtIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define read(a,n) for(int i = 0 ; i<n ; i++) cin>>a[i];
#define write(a) for(auto x : a) cout<<x<<" ";
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define el "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf=4e18;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,1,0,-1,1,-1,1,-1};
const int mod=1e9+7;
const int MAX =1e6+7;
// ---------------------------Function----------------------------------//
void TestCake(){
int all,n;
cin>>all>>n;
vector<int>arr(n);
read(arr,n);
map<int,int>mp;
for(auto x : arr)mp[x]++;
int ans=0;
map<int,int>tmp=mp;
int cnt=0;
for(int i=2;i<all;i++){
if(!tmp[i]&&!tmp[(i-1)]&&!tmp[i+1]){
cnt++;
tmp[i]=1;
}
}
if(!tmp[1]&&!tmp[all]&&!tmp[2]){
tmp[1]++;
cnt++;
}
if(!tmp[all]&&!tmp[all-1]&&!tmp[1]){
cnt++;
}
cout<<cnt;
}
//------------------------------Main---------------------------//
signed main(){
Major
int T = 1;
// cin >> T;
while(T--){
TestCake();
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
9 2 2 6
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 3 1 4 7
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
6 2 2 5
output:
0
result:
ok single line: '0'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
100 5 7 14 47 78 99
output:
42
result:
wrong answer 1st lines differ - expected: '43', found: '42'