QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#391580#3791. Interesting Calculatorucup-team1251Compile Error//Java82.0kb2024-04-16 17:15:412024-04-16 17:15:44

Judging History

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

  • [2024-04-16 17:15:44]
  • 评测
  • [2024-04-16 17:15:41]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define lson k << 1
#define rson (k << 1) | 1
#define debug cout << 666 << endl;
using namespace std;
const int N = 1e6 + 5;
int a[5][20];
int st[N];
int x, y;
struct aaa
{
    int value, cnt, now;
};
struct cmp
{
    bool operator()(const aaa &x, const aaa &y) const
    {
        if (x.value == y.value)
        {
            
            return x.cnt > y.cnt;
        }
        return x.value > y.value;
    }
};
void bfs()
{
    priority_queue<aaa, vector<aaa>, cmp> q;
    aaa k;
    k.cnt = 0, k.now = x, k.value = 0;
    st[k.now] = 1;
    q.push(k);
    while (!q.empty())
    {
        k = q.top();
        q.pop();
        // if(k.now==128)
        // {
        //     cout<<k.value<<" "<<k.cnt<<'\n';
        // }
        cout<<k.now<<" "<<k.value<<" "<<k.cnt<<'\n';
        if (k.now == y)
        {
            cout << k.value << " " << k.cnt << '\n';
            return;
        }
        for (int i = 1; i <= 3; i++)
        {
            for (int j = 0; j <= 9; j++)
            {
                aaa l;
                l.cnt = k.cnt + 1;
                l.value = k.value + a[i][j];
                if (i == 1)
                {
                    l.now = k.now * 10 + j;
                }
                else if (i == 2)
                {
                    l.now = k.now + j;
                }
                else
                {
                    l.now = k.now * j;
                }
                if (st[l.now] == 0 && l.now <= y)
                {
                    st[l.now] = 1;
                    q.push(l);
                }
            }
        }
    }
}
void vision()
{
    cin >> x >> y;
    for (int i = 1; i <= 3; i++)
    {
        for (int j = 0; j <= 9; j++)
        {
            cin >> a[i][j];
        }
    }
    bfs();
    return;
}
signed main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        vision();
    }
    return 0;
}

Details

Can't find the main class.