QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#825112#9750. 拼图DangXWA 2ms3840kbC++234.1kb2024-12-21 17:24:282024-12-21 17:24:35

Judging History

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

  • [2024-12-21 17:24:35]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3840kb
  • [2024-12-21 17:24:28]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
using namespace std;
const int Maxn = 1e5 + 5;
const int mod = 998244353;
int fac[Maxn], inv[Maxn];
int fast_pow(int a, int b)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return ans;
}
void C_init()
{
    fac[0] = 1;
    for (int i = 1; i < Maxn; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
    }

    inv[Maxn - 1] = fast_pow(fac[Maxn - 1], mod - 2);
    for (int i = Maxn - 2; i >= 0; i--)
    {
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
}
int C(int n, int m)
{
    if (m > n)
        return 0;
    if (m == 0)
        return 1;
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
void Map_init(int n)
{
    int mp[100][100];
    for (int i = 0; i <= n + 1; i++)
    {
        mp[i][0] = 0;
        mp[i][n + 1] = 0;
        mp[0][i] = 0;
        mp[n + 1][i] = 0;
    }
}
void bfs()
{
    int mp[100][100];
    int dx[5] = {0, -1, 0, 1};
    int dy[5] = {-1, 0, 1, 0};
    int n;
    struct node
    {
        int x, y;
    } S;
    queue<node> q;
    node T;
    q.push(S);
    while (!q.empty())
    {
        T = q.front();
        q.pop();
        for (int i = 0; i <= 3; i++)
        {
            int xx = T.x + dx[i];
            int yy = T.y + dy[i];
            if (xx < 0 || yy < 0 || xx > n + 1 || yy > n + 1 || mp[xx][yy] == 1 || mp[xx][yy] == 2)
                continue;
            mp[xx][yy] = 2;
            q.push((node){xx, yy});
        }
    }
}
void Dan_diao_queqe(int n, int k) // n--总长度  m--滑动区间
{
    int Data_n[1000005];
    deque<int> q;
    for (int i = 1; i <= n; i++)
        cin >> Data_n[i];
    for (int i = 1; i <= n; i++)
    {
        while (!q.empty() && Data_n[q.back()] > Data_n[i]) // 保证单调递增
            q.pop_back();                                  // 去尾
        q.push_back(i);
        if (i >= k)
        {
            while (!q.empty() && q.front() <= i - k)
                q.pop_front(); // 删头
            cout << Data_n[q.front()] << " ";
        }
    }
    cout << endl;
    while (!q.empty()) // 清空
        q.pop_front();
    for (int i = 1; i <= n; i++)
    {
        while (!q.empty() && Data_n[q.back()] < Data_n[i]) // 保证单调递减
            q.pop_back();                                  // 去尾
        q.push_back(i);
        if (i >= k)
        {
            while (!q.empty() && q.front() <= i - k)
                q.pop_front(); // 删头
            cout << Data_n[q.front()] << " ";
        }
    }
}
void Dan_diao_stack(int n)
{
    int a[3000005], lef[3000005], rig[3000005];
    stack<int> s;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= n; i++)
    {
        if (s.empty() || a[i] < a[s.top()])
            s.push(i);
        else
        {
            while (!s.empty() && a[i] > a[s.top()])
            {
                rig[s.top()] = i;
                s.pop();
            }
            s.push(i);
        }
    }
    while (!s.empty())
    {
        rig[s.top()] = 0;
        s.pop();
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int T;
    cin >> T;
    while (T--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int ans = 0;

        if (a >= 4)
            ans += 4;
        else
        {
            cout << 0 << endl;
            continue;
        }

        int cnt = 0;
        if (b >= c)
            cnt += c;
        else
            cnt += b;
        ans += cnt * 2;

        int minn = (cnt - 1);
        int maxx = 0;
        if (cnt % 2 == 1)
            maxx = ((cnt - 1) * (cnt + 1));
        else
            maxx = (cnt / 2) * (cnt / 2);

        if (d <= minn)
            ans += d;
        else if (d > maxx)
            ans += maxx;
        else
            ans += d;
        cout << ans << endl;
    }

    return 0;
} /*Orz Orz Orz ACACAC*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3484kb

input:

2
4 0 0 0
4 4 4 4

output:

4
16

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3840kb

input:

10000
0 0 0 0
0 0 0 1
0 0 0 2
0 0 0 3
0 0 0 4
0 0 0 5
0 0 0 6
0 0 0 7
0 0 0 8
0 0 0 9
0 0 1 0
0 0 1 1
0 0 1 2
0 0 1 3
0 0 1 4
0 0 1 5
0 0 1 6
0 0 1 7
0 0 1 8
0 0 1 9
0 0 2 0
0 0 2 1
0 0 2 2
0 0 2 3
0 0 2 4
0 0 2 5
0 0 2 6
0 0 2 7
0 0 2 8
0 0 2 9
0 0 3 0
0 0 3 1
0 0 3 2
0 0 3 3
0 0 3 4
0 0 3 5
0 0 3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 4332nd lines differ - expected: '10', found: '11'