제출 #835582

#제출 시각아이디문제언어결과실행 시간메모리
835582MadokaMagicaFan팀들 (IOI15_teams)C++14
34 / 100
4029 ms26668 KiB
#include "bits/stdc++.h" #include "teams.h" using namespace std; mt19937 rng(time(NULL)); int n; vector<int> a, b; vector<int> ord; struct node { int l, r; int v; int w; int s; } t[(int)5e5+5]; int size(int x) { if (x < 0) return 0; return t[x].s; } void upd(int x) { if (x < 0) return; t[x].s = 1 + size(t[x].l) + size(t[x].r); } int uni(int l, int r) { if (l < 0) return r; if (r < 0) return l; if (t[l].w > t[r].w) { t[l].r = uni(t[l].r, r); upd(l); return l; } else { t[r].l = uni(l, t[r].l); upd(r); return r; } } /* <= for left */ void splitv(int tp, int &l, int &r, int v) { if (tp == -1) { l = r = -1; return; } if (t[tp].v <= v) { l = tp; splitv(t[l].r, t[l].r, r, v); upd(l); } else { r = tp; splitv(t[r].l, l, t[r].l, v); upd(r); } } void splitk(int tp, int &l, int &r, int k) { if (tp == -1) { l = r = -1; return; } if (1 + size(t[tp].l) <= k) { l = tp; splitk(t[l].r, t[l].r, r, k - 1 - size(t[tp].l)); upd(l); } else { r = tp; splitk(t[r].l, l, t[r].l, k); upd(r); } } int can(int m, int K[]) { vector<int> k(m); for (int i = 0; i < m; ++i) k[i] = K[i]; sort(k.begin(), k.end()); int p1 = 0; int p2 = 0; int x, y, z, head = -1; for (int i = 1; i<= n; ++i) { while (p1 < n && a[ord[p1]] <= i) { x = ord[p1]; ++p1; t[x].l = t[x].r = -1; t[x].w = rng() % ((int)1e6); t[x].v = b[x]; upd(x); splitv(head, y, z, b[x]); head = uni(y, x); head = uni(head, z); } while (p2 < m && k[p2] <= i) { x = k[p2++]; splitv(head, head, z, x-1); if (size(z) < x) return 0; splitk(z, y, z, x); head =uni(head, z); } } return 1; } void init(int N, int A[], int B[]) { n = N; a.assign(n,0); b.assign(n,0); ord.assign(n,0); for (int i = 0; i < n; ++i) { ord[i] = i; a[i] = A[i]; b[i] = B[i]; } sort(ord.begin(), ord.end(), [&](int i, int j) { return a[i] < a[j]; }); }

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp: In function 'int can(int, int*)':
teams.cpp:90:19: warning: conversion from 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   90 |    t[x].w = rng() % ((int)1e6);
      |             ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...