QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#332341#6310. Dining ProfessorsScanoWA 8ms3612kbC++201.3kb2024-02-19 14:36:562024-02-19 14:36:57

Judging History

你现在查看的是最新测评结果

  • [2024-02-19 14:36:57]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3612kb
  • [2024-02-19 14:36:56]
  • 提交

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] && 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

5 2
1 0 1 0 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: -100
Wrong Answer
time: 8ms
memory: 3564kb

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:

274998

result:

wrong answer 1st numbers differ - expected: '279236', found: '274998'