Submission #368331

# Submission time Handle Problem Language Result Execution time Memory
368331 2021-02-19T22:33:29 Z farhan132 Library (JOI18_library) C++17
0 / 100
0 ms 364 KB
/***Farhan132***/

#include <bits/stdc++.h>
#include "library.h"
 
using namespace std;
 
typedef int ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<ll> vll;
typedef pair<ll , ll> ii;
typedef vector< ii > vii;
typedef pair < pair < ll , ll > , pair < ll , ll > > cm; 
 
#define ff first
#define ss second
#define pb push_back
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#define clean fflush(stdout)

const ll mod =  (ll)1e9 + 7;
const ll maxn = (ll)2e5 + 5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e9;
 
ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void Solve(int n){ 
  vector < ll > RES;
  if(n == 1){
    RES.pb(1);
    Answer(RES);
    return;
  }

  set < ll > s;
  for(ll i = 1; i <= n; i++){
    s.in(i);
  }

  ll ans[n+5];
  for(ll i = 1; i <= n; i++){
    s.erase(i);
    vector < ll > q(n);
    for(ll j = 1; j <= n; j++){
      q.pb(((bool)(s.count(j))));
    }
    if(Query(q) == 1){
      ans[1] = i;
      break;
    }
  }
  set < ll > final = s;

  for(ll i = 2; i <= n; i++){
    s = final;
    while(s.size() > 1){
      ll kk = s.size();
      set < ll > save = s;
      ll mid = (s.size()/2);
      vector < ll > q(n, 0);
      ll cnt = 0;
      for(ll j = 0; j < mid; j++){
        ll now = *s.begin();
        q[now-1] = 1; 
        s.erase(now);
      }
      ll x = Query(q);
      q[ans[i-1]-1] = 1;
      ll y = Query(q);
      if(x == y){
        set < ll > f;
        for(auto u : save){
          if(!s.count(u)) f.in(u) ;
        }
        s = f; 
        cnt = 1;
      }
    }
    ans[i] = *s.begin();
    final.erase(ans[i]);
  }
  vector < ll > res;
  for(ll i = 1; i <= n; i++) res.pb(ans[i]);
  Answer(res);
  return;
}
#ifdef LOCAL
 
int main() {
    
    
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #else 
     //   freopen("cbarn2.in", "r", stdin);
     //   freopen("cbarn2.out", "w", stdout);
        //ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    #endif
    //cout << fixed << setprecision(10);
   // work();
    //  mem(b,0);
    ll T;
    T=1;
    //cin >> T; 
    //scanf("%lld",&T);
   // ll CT = 0;
    //work();
    while(T--){
        //cout << "Case " << ++CT <<": " ;
        //printf("Case %lld: ",++CT);
        Solve(T+5);
    }
 
    return 0;
}
#endif

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:81:10: warning: unused variable 'kk' [-Wunused-variable]
   81 |       ll kk = s.size();
      |          ^~
library.cpp:85:10: warning: variable 'cnt' set but not used [-Wunused-but-set-variable]
   85 |       ll cnt = 0;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -