제출 #43476

#제출 시각아이디문제언어결과실행 시간메모리
43476nonocut팀들 (IOI15_teams)C++14
0 / 100
3351 ms75356 KiB
#include "teams.h" #include<bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() const int maxn = 5e5 + 5; int n; vector<int> tree[maxn]; vector<int>::iterator used[maxn]; int pos[maxn]; void add(int x, int y) { while(x<=n) { tree[x].push_back(y); x += x&-x; } } int query(int x, int y) { int res = 0; while(x>0) { if(!tree[x].empty()) { auto it = --upper_bound(all(tree[x]), y); res += it - used[x]; } x -= x&-x; } return res; } void change(int x, int y) { while(x>0) { if(!tree[x].empty()) used[x] = --upper_bound(all(tree[x]), y); x -= x&-x; } } void reset(int x) { while(x>0) { used[x] = --tree[x].begin(); x -= x&-x; } } void init(int N, int A[], int B[]) { n = N; for(int i=0;i<n;i++) add(A[i],B[i]); for(int i=1;i<=n;i++) { used[i] = --tree[i].begin(); sort(all(tree[i])); } } int can(int m, int K[]) { int res = 1; sort(K, K+m); for(int i=0;i<m;i++) { int l = 1, r = n, mid; pos[i] = -1; while(l<=r) { mid = (l+r)/2; if(query(K[i],mid) >= K[i]) { pos[i] = mid; r = mid-1; } else l = mid+1; } if(pos[i]==-1) res = 0; change(K[i], pos[i]); } for(int i=0;i<m;i++) reset(K[i]); return res; }

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

teams.cpp: In function 'int query(int, int)':
teams.cpp:26:17: warning: conversion to 'int' from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type {aka long int}' may alter its value [-Wconversion]
             res += it - used[x];
                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...