QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#332351 | #6310. Dining Professors | Scano | WA | 8ms | 3816kb | C++20 | 1.4kb | 2024-02-19 14:42:43 | 2024-02-19 14:42:44 |
Judging History
answer
#include <bits/stdc++.h>
#define sz(v) v.size()
#define forn(i,n) for(int i = 0; i < n; ++i)
#define fi first
#define se second
#define el '\n'
#define all(v) v.begin(),v.end()
#define pb push_back
#define d(x) cout << #x << " : " << x << el
using namespace std;
typedef pair<int,int> ii;
int dr[] = {1,0,-1,0};
int dc[] = {0,1,0,-1};
const int nax = 1e5 + 20;
vector<int> g[nax];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cout << setprecision(20)<< fixed;
int n, cnt;
cin >> n >> cnt;
cnt = n - cnt;
vector<int> a(n);
vector<bool> pos(n);
int ans = 0;
forn(i,n){
cin >> a[i];
if(a[i]==1) ans += 3;
}
forn(i,n){
if(!a[(i+1)%n] && !a[i] && !a[(i-1+n)%n] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!a[(i+1)%n] && a[i] && !a[(i-1+n)%n] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!pos[i] && !a[i] && !a[(i+1)%n] && cnt){
pos[i] = 1;
--cnt;
}
if(!pos[i] && !a[i] && !a[(i-1+n)%n] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!pos[i] && (!a[(i-1+n)%n] || !a[(i+1)%n]) && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!pos[i] && cnt){
pos[i] = 1;
--cnt;
}
}
forn(i,n){
if(!a[i]){
ans += (pos[i] + pos[(i+1)%n] + pos[(i-1+n)%n]);
}
}
cout << ans << el;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
input:
5 2 1 0 1 0 1
output:
13
result:
ok 1 number(s): "13"
Test #2:
score: 0
Accepted
time: 8ms
memory: 3780kb
input:
100000 33292 1 1 1 1 0 1 1 0 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 0...
output:
279236
result:
ok 1 number(s): "279236"
Test #3:
score: 0
Accepted
time: 8ms
memory: 3564kb
input:
100000 91906 1 1 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 0 0 1 0 1 0 1 1 0 0 1 0...
output:
174297
result:
ok 1 number(s): "174297"
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 3564kb
input:
100000 1825 0 0 0 1 0 0 1 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 1 0 0 1 1 0 0 1 0 1 1 1 ...
output:
299132
result:
wrong answer 1st numbers differ - expected: '300000', found: '299132'