QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292329#7522. Sequence ShiftGeothermalRE 0ms3824kbC++173.9kb2023-12-28 01:04:552023-12-28 01:04:55

Judging History

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

  • [2023-12-28 01:04:55]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3824kb
  • [2023-12-28 01:04:55]
  • 提交

answer

#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define dbg(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl;
#else
#define dbg(x...)
#endif


const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; 

void solve() {
    int N, Q; cin >> N >> Q;
    int NN = max(N, 10);
    ld prob = 1 - pow(1/((ld)NN), 1/((ld)(NN-1)));
    ld lo = 1, hi = 2;
    F0R(iter, 300) {
        ld mid = (lo+hi)/2;
        ld val = (2-mid)/2 - (2-mid)*(2-mid)/4;
        if (val < prob) {
            hi = mid;
        } else lo = mid;
    }
    int cap = 1e9 * lo;
    int ans[Q+1]; F0R(i, Q+1) ans[i] = 0;
    vi A(N);
    vi B(N);
    vpi As;
    F0R(i, N) {
        cin >> A[i];
        As.pb({A[i], i});
    }
    sort(all(As)); reverse(all(As));
    F0R(i, N) cin >> B[i];
    F0R(i, N) {
        F0R(j, N) {
            if (B[i] + As[j].f < cap) break;
            if (As[j].s > i) continue;
            if (Q <= i-As[j].s) {
                ckmax(ans[i-As[j].s], As[j].f+B[i]);
            }
        }
    }

    F0R(q, Q+1) {
        if (ans[q] == 0) {
            F0R(i, N) {
                ckmax(ans[q], A[i] + B[i+q]);
            }
        }
        cout << ans[q] << nl;
        if (q == Q) break;
        int V; cin >> V; V ^= ans[q];
        B.pb(V);
        F0R(j, N) {
            if (V + As[j].f < cap) break;
            if (Q <= q+N-As[j].s) {
                ckmax(ans[q+N-As[j].s], As[j].f+V);
            }
        }
    }

}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }

	return 0;
}




Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:

11
13
16
25

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

1 10
700282491
332230980
90825676
1630266999
644973380
262379760
2122877054
1851957134
1370195232
110993724
1319359505
1883523208

output:

1032513471
1654684398
759763732
888538827
1695749302
1163465539
1425605448
789576931
1397740634
1202288326
1638577353

result:

ok 11 lines

Test #5:

score: -100
Runtime Error

input:

1000 100000
438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...

output:

1962871590
1986083253
1967509108
1973351244
1974354421
1956371849
1976394149
1995721753
1946870160
1984280254
1961237540
1955903880
1944520591
1937726835
1993563403
1927000559
1951483558
1979133252
1979156812
1941301401
1922284543
1980597785
1963663583
1946961524
1933606347
1953947075
1953071855
194...

result: