제출 #800395

#제출 시각아이디문제언어결과실행 시간메모리
800395erray팀들 (IOI15_teams)C++17
77 / 100
4115 ms331664 KiB
#pragma GCC optimize("O3,avx2") #include "teams.h" #include<bits/stdc++.h> using namespace std; #ifdef DEBUG #include "/home/ioi/codes/ioi15_d1/debug.h" #else #define debug(...) void(37) #endif template<typename T> vector<T> inverse_fuck(T* a, int N) { vector<T> res(N); for (int i = 0; i < N; ++i) { res[i] = a[i]; } return res; } int ll = -1; namespace PST { struct node { node* l = NULL; node* r = NULL; int sum = 0; }; node* modify(node* prev, int l, int r, int p) { debug(l, r); node* v = new node(); if (prev != NULL) { v->l = prev->l; v->r = prev->r; v->sum = prev->sum; } v->sum += 1; if (l < r) { int mid = (l + r) >> 1; if (p <= mid) { v->l = modify(v->l, l, mid, p); } else { v->r = modify(v->r, mid + 1, r, p); } } return v; } int get(node* v, int l, int r) { if (l >= ll) { return v->sum; } int mid = (l + r) >> 1; int res = 0; if (ll <= mid) { res += (v->l == NULL ? 0 : get(v->l, l, mid)); res += (v->r != NULL ? v->r->sum : 0); } else if (v->r != NULL) { res += get(v->r, mid + 1, r); } return res; } } struct SegTree { int n; vector<PST::node*> roots; SegTree(int _n) : n(_n) { roots.resize(1); roots[0] = new PST::node(); } SegTree() { } PST::node* modify(int x) { roots.push_back(PST::modify(roots.back(), 0, n - 1, x)); return roots.back(); } int get(PST::node* v) { return PST::get(v, 0, n - 1); } }; int N; vector<array<int, 2>> A; SegTree st; vector<PST::node*> vers; vector<int> pt; void init(int __N, int __A[], int __B[]) { N = __N; auto L = inverse_fuck(__A, N); auto R = inverse_fuck(__B, N); debug(N, L, R); A.resize(N); for (int i = 0; i < N; ++i) { A[i] = array<int, 2>{L[i], R[i]}; } sort(A.begin(), A.end()); debug(A); st = SegTree(N + 1); for (int i = 0; i < N; ++i) { debug(i); auto v = st.modify(A[i][1]); if (i == N - 1|| A[i + 1][0] != A[i][0]) { pt.push_back(A[i][0]); vers.push_back(v); } } } int can(int M, int __K[]) { auto K = inverse_fuck(__K, M); sort(K.begin(), K.end()); if (accumulate(K.begin(), K.end(), 0LL) > N) { return false; } debug(M, K); vector<array<int, 2>> comp; for (int i = 0; i < M; ++i) { if (i == 0 || comp.back()[0] != K[i]) { comp.push_back({K[i], 0}); //overflow on sums } comp.back()[1] += K[i]; } auto Contains = [&](int l, int r) { ll = r; return (l == -1 ? 0 : st.get(vers[l])); }; int s = int(comp.size()); vector<int> from(s); int p = -1; for (int i = 0; i < s; ++i) { while (p + 1 < int(pt.size()) && pt[p + 1] <= comp[i][0]) { ++p; } from[i] = p; } debug(comp, from); vector<int> dp(s); for (int i = 0; i < s; ++i) { auto[x, sz] = comp[i]; dp[i] = 0; for (int j = 0; j < i; ++j) { dp[i] = min(dp[i], dp[j] - Contains(from[j], x)); } dp[i] += Contains(from[i], x) - sz; if (dp[i] < 0) { return false; } } return true; }

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

teams.cpp:1:31: warning: bad option '-favx2' to pragma 'optimize' [-Wpragmas]
    1 | #pragma GCC optimize("O3,avx2")
      |                               ^
In file included from teams.cpp:2:
teams.h:4:34: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
    4 | void init(int N, int A[], int B[]);
      |                                  ^
teams.h:4:34: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
teams.h:5:23: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
    5 | int can(int M, int K[]);
      |                       ^
teams.h:5:23: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
teams.cpp:15:35: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   15 | vector<T> inverse_fuck(T* a, int N) {
      |                                   ^
teams.cpp:30:47: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   30 |   node* modify(node* prev, int l, int r, int p) {
      |                                               ^
teams.cpp:49:32: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   49 |   int get(node* v, int l, int r) {
      |                                ^
teams.cpp:68:17: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   68 |   SegTree(int _n) : n(_n) {
      |                 ^
teams.cpp:72:11: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   72 |   SegTree() { }
      |           ^
teams.cpp:73:26: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   73 |   PST::node* modify(int x) {
      |                          ^
teams.cpp:77:23: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   77 |   int get(PST::node* v) {
      |                       ^
teams.cpp:87:40: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
   87 | void init(int __N, int __A[], int __B[]) {
      |                                        ^
teams.cpp:110:25: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
  110 | int can(int M, int __K[]) {
      |                         ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:124:35: warning: bad option '-favx2' to attribute 'optimize' [-Wattributes]
  124 |   auto Contains = [&](int l, int r) {
      |                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...