Submission #348845

#TimeUsernameProblemLanguageResultExecution timeMemory
348845dennisstarTeams (IOI15_teams)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define eb emplace_back using namespace std; const int MX = 5e5 + 5; vector<int> st[1<<20]; void upd(int i, int s, int e, int t, int v) { st[i].eb(v); if (s==e) return ; int m=(s+e)/2; if (t<=m) upd(i*2, s, m, t, v); else upd(i*2+1, m+1, e, t, v); } void init(int i, int s, int e) { sort(st[i].begin(), st[i].end()); if (s==e) return ; int m=(s+e)/2; init(i*2, s, m); init(i*2+1, m+1, e); } struct { int used; int l, r; }nd[1<<23]; int nc; int use(int n, int i, int s, int e, int w, int v) { int t=upper_bound(st[i].begin(), st[i].end(), w)-st[i].begin(); if (t-nd[n].used<=v) { int r=t-nd[n].used; nd[n].used=t; return r; } if (s==e) { nd[n].used+=v; return v; } int m=(s+e)/2; if (!nd[n].l) { assert(nd[n].used==0); nd[n].l=++nc; nd[n].r=++nc; } int x=use(nd[n].l, i*2, s, m, w, v); int y=(x==v?0:use(nd[n].r, i*2+1, m+1, e, w, v-x)); nd[n].used=nd[nd[n].l].used+nd[nd[n].r].used; return x+y; } void kill(int n, int i, int s, int e, int t) { if (t<s) return ; if (e<=t) { nd[n].used=st[i].size(); return ; } int m=(s+e)/2; if (!nd[n].l) { nd[n].l=++nc; nd[n].r=++nc; } kill(nd[n].l, i*2, s, m, t); kill(nd[n].r, i*2+1, m+1, e, t); nd[n].used=nd[nd[n].l].used+nd[nd[n].r].used; } int N, Q; int sol() { int M; cin>>M; vector<int> K(M); for (auto &i:K) cin>>i; sort(K.begin(), K.end()); int rt=++nc; for (auto &i:K) { kill(rt, 1, 1, N, i-1); if (use(rt, 1, 1, N, i, i)<i) return 0; } return 1; } int main() { cin.tie(0)->sync_with_stdio(0); cin>>N; for (int i=1, a, b; i<=N; i++) cin>>a>>b, upd(1, 1, N, b, a); init(1, 1, N); cin>>Q; while (Q--) cout<<sol()<<'\n'; return 0; }

Compilation message (stderr)

teams.cpp: In function 'int use(int, int, int, int, int, int)':
teams.cpp:32:50: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   32 |  int t=upper_bound(st[i].begin(), st[i].end(), w)-st[i].begin();
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
teams.cpp: In function 'void kill(int, int, int, int, int)':
teams.cpp:56:35: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   56 |  if (e<=t) { nd[n].used=st[i].size(); return ; }
      |                         ~~~~~~~~~~^~
/tmp/ccKRB9rJ.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccqTW9Dn.o:teams.cpp:(.text.startup+0x0): first defined here
/tmp/ccKRB9rJ.o: In function `main':
grader.c:(.text.startup+0x3c4): undefined reference to `init(int, int*, int*)'
grader.c:(.text.startup+0x6b7): undefined reference to `can(int, int*)'
collect2: error: ld returned 1 exit status