QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#326556#5533. Trickhotboy27030 0ms0kbC++143.1kb2024-02-13 13:53:102024-02-13 13:53:11

Judging History

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

  • [2024-02-13 13:53:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-02-13 13:53:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
mt19937_64 rng(1);
mt19937_64 rng2(chrono::steady_clock::now().time_since_epoch().count());
ll random2(ll l,ll r){
    return rng2()%(r-l+1)+l;
}
ll random(ll l,ll r){
    return rng()%(r-l+1)+l;
}
ll myrandom(ll i){
    return rng()%i;
}
ll base1=998244353, base2=1e9+7;
ll match[505][505];
const ll MOD = 10000121;
ll random_val[MOD];

ll f(ll x,ll y,ll n){
    ll val = ((random_val[x]%MOD+500)*(2*n+5)+random_val[y]%MOD+1+69420)*45;
    val += MOD/2;
    val = val%MOD;
    val = val*val%MOD;
    return random_val[val]%(2*n+1);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    for (ll i = 0;i < MOD;i ++)random_val[i] = rng();
    ll t, type; cin >> t >> type;
    auto assistant_small=[&](ll n)
    {
        ll sum=0, Mod=n*2+1;
        vector <ll> a(n);
        for (ll& i:a) cin >> i, sum=(sum+i)%Mod;
        for (ll i=0; i<n; i++)
            for (ll j=0; j<n; j++)
                if (i!=j && match[a[i]][a[j]]==sum)
                {
                    cout << a[i] << " " << a[j] << "\n";
                    return;
                }
    };
    auto magician_small=[&](ll n)
    {
        ll Mod=n*2+1, fa1, fb1, fa2, fb2; cin >> fa1 >> fb1 >> fa2 >> fb2;
        ll sum=match[fa1][fb1]+match[fa2][fb2];
        sum=((n*2+1-sum)%Mod+Mod)%Mod; cout << sum << "\n";
    };
    auto assistant=[&](ll n)
    {
        ll sum=0, fa=0, fb=0, Mod=n*2+1;
        vector <ll> a(n);
        for (ll& i:a) cin >> i, sum=(sum+i)%Mod;
        sort(a.begin(), a.end());
        for (ll i=0; i<n; i++)
            for (ll j=i+1; j<n; j++)
            {
                if ((a[i]+a[j])%Mod==sum) fa=a[i], fb=a[j];
                if ((a[i]+a[j]+n)%Mod==sum) fa=a[j], fb=a[i];
            }
        cout << fa << " " << fb << "\n";
    };
    auto magician=[&](ll n)
    {
        ll Mod=n*2+1, fa1, fb1, fa2, fb2; cin >> fa1 >> fb1 >> fa2 >> fb2;
        ll sum=(fa1<fb1?fa1+fb1:fa1+fb1+n)+(fa2<fb2?fa2+fb2:fa2+fb2+n);
        sum=((n*2+1-sum)%Mod+Mod)%Mod; cout << sum << "\n";
    };
    while (t--)
    {
        ll n; cin >> n;
            if (type==3){
                ll a,b,c,d;
                cin>>a>>b>>c>>d;
                ll res = -(f(a,b,n)+f(c,d,n));
                res = (res%(2*n+1)+2*n+1)%(2*n+1);
                cout<<res<<'\n';
            }
            else{
                vector <ll> a(n);
                ll sum = 0;
                for (auto &x:a){cin>>x;sum = (sum+x)%(2*n+1);}
                ll u,v;
                u = random2(0,sz(a)-1);
                v = random2(0,sz(a)-1);
                while ((u == v || f(a[u],a[v],n) != sum)){
                    u = random2(0,sz(a)-1);
                    v = random2(0,sz(a)-1);
                }
                cout<<a[u]<<' '<<a[v]<<'\n';
            }
        
    }
}

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

12012
1
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 5
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 4 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 6
6
0 1 2 3 5 ...

output:


result:


Subtask #2:

score: 0
Skipped

Subtask #3:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

6525
1
6
10 1 11 3 12 6
6
1 7 10 12 5 6
6
0 10 12 7 9 8
6
12 1 8 4 7 11
6
11 8 9 4 10 6
6
0 7 2 3 4 5
6
0 8 3 10 11 6
6
0 1 2 4 7 6
6
0 1 11 9 5 6
6
7 1 12 8 6 5
7
0 1 13 10 12 5 6
7
0 14 2 3 4 12 6
7
11 1 3 8 12 6 13
7
0 1 2 3 13 5 14
7
11 9 10 8 4 14 7
7
0 8 14 3 4 13 11
7
0 10 2 14 8 5 6
7
0 13 2...

output:


result:


Subtask #4:

score: 0
Skipped