Submission #1003842

#TimeUsernameProblemLanguageResultExecution timeMemory
1003842AdamGSLibrary (JOI18_library)C++17
100 / 100
151 ms708 KiB
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
void Solve(int n) {
  vector<vector<int>>V;
  V.pb({0});
  for(int i=1; i<n; ++i) {
    vector<int>T(n);
    rep(j, i+1) T[j]=1;
    int a=Query(T);
    if(a>V.size()) {
      V.pb({i});
      continue;
    }
    int po=0, ko=V.size()-1;
    while(po<ko) {
      int sr=(po+ko)/2;
      rep(j, n) T[j]=0;
      rep(j, sr+1) rep(l, V[j].size()) T[V[j][l]]=1;
      T[i]=1;
      int x=Query(T);
      if(x>sr+1) po=sr+1; else ko=sr;
    }
    rep(j, n) T[j]=0;
    T[i]=1;
    T[V[po].back()]=1;
    if(Query(T)==2) reverse(all(V[po]));
    V[po].pb(i);
    if(a==V.size()) continue;
    int b=po;
    po=b+1; ko=V.size()-1;
    while(po<ko) {
      int sr=(po+ko)/2;
      rep(j, n) T[j]=0;
      for(int j=b+1; j<=sr; ++j) rep(l, V[j].size()) T[V[j][l]]=1;
      T[i]=1;
      int x=Query(T);
      if(x>sr-b) po=sr+1; else ko=sr;
    }
    rep(j, n) T[j]=0;
    T[i]=1;
    T[V[po][0]]=1;
    if(Query(T)==2) reverse(all(V[po]));
    for(auto j : V[po]) V[b].pb(j);
    for(int j=po+1; j<V.size(); ++j) V[j-1]=V[j];
    V.pop_back();
  }
  rep(i, V[0].size()) ++V[0][i];
  Answer(V[0]);
}

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:17:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     if(a>V.size()) {
      |        ~^~~~~~~~~
library.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
library.cpp:25:20: note: in expansion of macro 'rep'
   25 |       rep(j, sr+1) rep(l, V[j].size()) T[V[j][l]]=1;
      |                    ^~~
library.cpp:35:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(a==V.size()) continue;
      |        ~^~~~~~~~~~
library.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
library.cpp:41:34: note: in expansion of macro 'rep'
   41 |       for(int j=b+1; j<=sr; ++j) rep(l, V[j].size()) T[V[j][l]]=1;
      |                                  ^~~
library.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int j=po+1; j<V.size(); ++j) V[j-1]=V[j];
      |                     ~^~~~~~~~~
library.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
library.cpp:54:3: note: in expansion of macro 'rep'
   54 |   rep(i, V[0].size()) ++V[0][i];
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...