QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#754333#9548. The Foolucup-team3646#Compile Error//Python32.1kb2024-11-16 14:48:052024-11-16 14:48:07

Judging History

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

  • [2024-11-16 14:48:07]
  • 评测
  • [2024-11-16 14:48:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, l, r) for (ll i = l; i < r; i++)

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

/* ---- */
#define all(A) A.begin(), A.end()
#define elif else if
using pii = pair<ll, ll>;

bool chmin(auto &a, const auto &b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, const auto &b) { return a < b ? a = b, 1 : 0; }

struct IOSetup {
  IOSetup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} iosetup;

template <class T>
void print(vector<T> a) {
  for (auto x : a) cerr << x << ' ';
  cerr << endl;
}

void print(auto x) { cerr << x << endl; }

template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  cerr << head << ' ';
  print(forward<Tail>(tail)...);
}

int sisya(int c){
  if(c<5)return 0;
  else return 10;
}

bool valid(ll c,bool cl,ll x,bool xl){
  vll numlist;
  if(xl)numlist={sisya(c),c};
  else numlist={sisya(c+1),sisya(c)+1,c+1};
  for(int n:numlist){
    if(n%10==x){
      if(n>=10&&cl)return 1;
      if(n<10&&!cl)return 1;
    }
  }
  return 0;
}

bool next_lower(int c,int x,int isl){
  if(c<x)return 1;
  else if(c==x&&isl)return 1;
  return 0;
}

const ll imax = 20;
ll dp[imax + 1][2][2];

void init() {
  rep(i, imax + 1) rep(j, 2) rep(k, 2) dp[i][j][k] = 0;
  return;
}

void solve(){
  init();
  string X, Z; cin >> X >> Z;
  while(X.size() <= imax) {
    X = '0' + X;
  }
  while (Z.size() <= imax) {
    Z = '0' + Z;
  }
  reverse(X.begin(), X.end());
  reverse(all(Z));

  dp[0][1][0] = 1;
  rep(i, imax) {
    rep(islow0, 2) {
      rep(l0, 2) {
        rep(c, 10) {
          ll nex = next_lower(c, Z[i] - '0' , islow0);
          rep(l1, 2) {
            if (valid(c, l1, X[i] - '0', islow0));
            dp[i+1][nex][l1] += dp[i][islow0][l0];
          }
        }
      }
    }
  }
  
  ll res = dp[imax][1][0];
  cout << res << endl;

  return;
}

int main(){
    int T;
    cin>>T;
    while(T--)
    solve();
}

Details

  File "answer.code", line 2
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax