QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#322044#4830. Transfer of DutyGoldenglow14270 0ms0kbC++141.8kb2024-02-06 08:16:302024-02-06 08:16:31

Judging History

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

  • [2024-02-06 08:16:31]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-02-06 08:16:30]
  • 提交

answer

/*
ID: Victor Chen [mail_vi1]
PROG: Transfer of Duty
LANG: C++
*/

#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

const int Maxn = 1e5;

const ll mod1 = 19260817;
const ll mod2 = 1e9+7;

map<ll, int> mp1, mp2;

int n;
ll a1[Maxn+10], a2[Maxn+10];
ll res1, res2;

char str[Maxn+10];

void solve1()
{
    cin >> n;

    mp1[1] = mp2[1] = 1;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin >> x;

        res1 ^= a1[x];
        res2 ^= a2[x];

        if(res1 == 0 && res2 == 0)
            printf("0\n");
        else
        {
            int k1 = mp1[res1], k2 = mp2[res2];
            if(k1 == 0 || k2 == 0 || k1 != k2)
                printf("-1\n");
            else
                printf("%d\n", k1);
        }
    }

    cout << res1 << " " << res2 << endl;
}

void solve2()
{
    cin >> res1 >> res2;

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin >> x;

        res1 ^= a1[x];
        res2 ^= a2[x];

        if(res1 == 0 && res2 == 0)
            printf("0\n");
        else
        {
            int k1 = mp1[res1], k2 = mp2[res2];
            if(k1 == 0 || k2 == 0 || k1 != k2)
                printf("-1\n");
            else
                printf("%d\n", k1);
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);

    a1[1] = a2[1] = 1;
    for(int i=2; i<=Maxn; i++)
    {
        a1[i] = a1[i-1] * 2;
        a1[i] %= mod1;

        a2[i] = a1[i-1] * 2;
        a1[i] %= mod2;

        mp1[a1[i]] = i;
        mp2[a2[i]] = i;
    }

    cin >> str+1;
    if(str[1] == 's')
        solve1();
    else
        solve2();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer on the first run

input:

start
5
10
14
10
12
10

output:

10752 10752
10
-1
14
-1
-1

input:


output:


result:

wrong output format Expected EOLN