QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747641#9627. 算术kindow#WA 1ms3552kbC++201.4kb2024-11-14 17:45:282024-11-14 17:45:29

Judging History

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

  • [2024-11-14 17:45:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3552kb
  • [2024-11-14 17:45:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
void solve(){
  vector<ll> a(10);
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for(ll i = 1; i <= 9; ++i){
    cin >> a[i];
    if(i != 1){
      for(ll j = 1; j <= a[i]; ++j){
        pq.push(i);
      }
    }
  }
  auto get_val = [](priority_queue<ll, vector<ll>, greater<ll>> pq) -> ll {
    ll ans = 1;
    while(!pq.empty()){
      ans *= pq.top();
      ans %= mod;
      pq.pop();
    }
    return ans;
  };
  if(pq.empty()){
    int cur = ceil(double(a[1]) / 3.0);
    int two = 3 * cur - a[1];
    int th = (a[1] - two * 2) / 3;
    for(int i = 1; i <= two; ++i){
      pq.push(2);
    }
    for(int i = 1; i <= th; ++i){
      pq.push(3);
    }
    cout << get_val(pq) << '\n';
    return;
  }
  while(pq.top() <= 2 && a[1] >= 0){
    pq.pop();
    pq.push(3);
    a[1]--;
  }
  if(a[1] == 1){
    pq.push(pq.top() + 1);
    pq.pop();
  }
  else{
    int cur = ceil(double(a[1]) / 3.0);
    int two = 3 * cur - a[1];
    int th = (a[1] - two * 2) / 3;
    for(int i = 1; i <= two; ++i){
      pq.push(2);
    }
    for(int i = 1; i <= th; ++i){
      pq.push(3);
    }
  }
  cout << get_val(pq) << '\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll t = 1;
  cin >> t;
  while(t--){
    solve();
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3552kb

input:

7
5 3 0 0 0 0 0 0 0
4 1 1 1 0 0 0 0 0
1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 2
99 88 77 66 55 44 33 22 11
100 90 80 70 60 50 40 30 20

output:

54
108
4
10
90
90553232
143532368

result:

wrong answer 3rd lines differ - expected: '1', found: '4'