QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611320#6669. Mapastaring0 1ms3852kbC++142.6kb2024-10-04 20:22:282024-10-04 20:22:29

Judging History

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

  • [2024-10-04 20:22:29]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3852kb
  • [2024-10-04 20:22:28]
  • 提交

answer

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

constexpr int N = 105, MOD = 1e9 + 7;

namespace Alice
{
    int n;

    int a[N][N];

    int inverse(int x)
    {
        int y = 1, c = MOD - 2;
        while(c)
        {
            if(c & 1)y = 1ll * y * x % MOD;
            x = 1ll * x * x % MOD, c >>= 1;
        }
        return y;
    }

    void work()
    {
        for(int i = 0; i < n; i ++)
        {
            int t = i;
            while(t <= n && a[t][i] == 0) t ++;
            swap(a[i], a[t]);

            int inv = inverse(a[i][i]);
            for(int j = i; j <= n; j ++)
                a[i][j] = 1ll * a[i][j] * inv % MOD;
            
            for(int j = i + 1; j < n; j ++)
            {
                if(a[j][i] == 0)continue;
                for(int k = n; k >= i; k --)
                    a[j][k] = (a[j][k] - 1ll * a[i][k] * a[j][i] % MOD + MOD) % MOD;
            }
        }

        for(int i = n - 1; i >= 0; i --)
            for(int j = i - 1; j >= 0; j --)
                a[j][n] = (a[j][n] - 1ll * a[j][i] * a[i][n] % MOD + MOD) % MOD;
    }

    void solve()
    {
        scanf("%d", &n);
        for(int i = 0; i < n; i ++)
        {
            int x, y;
            scanf("%d%d", &x, &y);

            int w = 1;
            for(int j = 0; j < n; j ++)
            {
                a[i][j] = w;
                w = 1ll * w * x % MOD;
            }
            a[i][n] = y;
        }

        work();

        printf("%d\n", n * 30);
        for(int i = 0; i < n; i ++)
        {
            for(int j = 0; j < 30; j ++)
                printf("%d", a[i][n] >> j & 1);
        }
    }
}

namespace Bob
{
    int n;

    char str[N * 30];
    int a[N];

    int work(int x)
    {
        int w = 1, y = 0;
        for(int i = 0; i < n; i ++)
        {
            y = (y + 1ll * a[i] * w % MOD) % MOD;
            w = 1ll * w * x % MOD;
        }
        return y;
    }

    void solve()
    {
        int m, q;
        scanf("%d%d%d", &n, &q, &m);
        scanf("%s", str);
        n /= 30;

        for(int i = n - 1; i >= 0; i --)
        {
            int val = 0;
            for(int j = 29; j >= 0; j --)
                val = val << 1 | (str[i * 30 + j] - '0');
            a[i] = val;
        }

        while(q --)
        {
            int x;
            scanf("%d", &x);

            printf("%d\n", work(x));
        }
    }
}

int main()
{
    int T;
    scanf("%d", &T);

    if(T==1)Alice :: solve();
    else Bob :: solve();

    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms = 1ms + 0ms
memory: 3852kb,3808kb

input:

1
100
495528311 963488152
269613430 443544124
700489871 792354118
151890319 506569919
180452297 13229948
684464994 543841485
978085128 903812192
238355172 441140842
28061035 783291471
530823766 718942732
936853023 439421263
201361623 226633955
304644844 778868118
864860135 461524170
88300500 6959354...

output:

3000
1010001011000001001110110011100001011110110001101101001000110001110110101011111100011100101100100011001000111010010100001101011101001111001010110110110100000011110111100010111100010011100111110101100010110011000001101001111111110101100100101010001000110101001110101010100011011110100001100110100...

input:

2
100 79 3000
1010001011000001001110110011100001011110110001101101001000110001110110101011111100011100101100100011001000111010010100001101011101001111001010110110110100000011110111100010111100010011100111110101100010110011000001101001111111110101100100101010001000110101001110101010100011011110100001...

output:

214689701
676741981
59724752
548860089
835843653
834974016
458365711
983554912
571741977
507064893
55907014
364012636
786667918
368478334
405059194
83021833
338975060
256099099
411243766
834364888
152107722
125150313
506111248
132202720
192755183
890214456
545588860
524373889
668299646
735987453
110...

result:

wrong answer wrong answer on query #1: read 214689701 but expected 310305144