답안 #654388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654388 2022-10-31T08:30:45 Z Hiennoob123 도서관 (JOI18_library) C++14
0 / 100
80 ms 464 KB
#include<bits/stdc++.h>
#include "library.h"
#define ll int
//#define int long long
#define ld long double
#define cd complex<ld>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std ;
ll n ;
bool check[1005] ;
vector<ll> T[1005] ;
vector<pll> Edge ;
ll ask(ll l , ll r , ll num)
{
    vector<ll> que1(n , 0) , que2(n , 0) ;
    que1[num-1] = 1 ;
    for(int i = l ; i<= r ; i++)
    {
        que1[i-1] = que2[i-1] = 1 ;
    }
    return (r-l+2-Query(que1)) - (r-l+1-Query(que2)) ;
}
void dnc(ll l , ll r , ll num)
{
    if(r-l<1)
    {
        return ;
    }
    //cout << l << " " << r << " " << num << "\n" ;
    ll mid = ((l+r)>>1) ;
    ll this1 = ask(l , mid , num) , this2 = ask(mid+1 , r , num) ;
    if(this1>0)
    {
        if(l==mid)
        {
            Edge.push_back(mp(num , l)) ;
        }
        else
        {
            dnc(l , mid , num) ;
        }
    }
    if(this2>0)
    {
        if(r==mid+1)
        {
            Edge.push_back(mp(num , r)) ;
        }
        else
        {
            dnc(mid+1 , r , num) ;
        }
    }
}
void Solve(int m)
{
    n = m ;
    //cout << n << " " << m << endl ;
    for(int i = 1 ; i< n-1 ; i++)
    {
        dnc(i+1 , n , i) ;
    }
    if(n>1)
    {
        vector<ll> que(n , 0);
        que[n-1] = que[n-2] = 1 ;
        if(Query(que)==1) Edge.push_back(mp(n-1 , n)) ;
    }
    for(int i = 0; i< Edge.size() ; i++)
    {
        //cout << Edge[i].fi << " " << Edge[i].se << "\n" ;
        T[Edge[i].fi].push_back(Edge[i].se) ;
        T[Edge[i].se].push_back(Edge[i].fi) ;
    }
    vector<ll> ans ;
    queue<ll> q ;
    for(int i = 1 ; i<= n ; i++)
    {
        if(T[i].size()==1)
        {
            q.push(i) ;
            break ;
        }
    }
    while(!q.empty())
    {
        ll x = q.front();
        q.pop() ;
        if(check[x]) continue ;
        check[x] = 1 ;
        ans.push_back(x) ;
        //cout << x << " " ;
        for(int i = 0; i< T[x].size() ; i++)
        {
            q.push(T[x][i]) ;
        }
    }
    assert(ans.size()>=n) ;
    //cout << ans.size() << "-1" << endl;
    Answer(ans) ;
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:75:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(int i = 0; i< Edge.size() ; i++)
      |                    ~^~~~~~~~~~~~~
library.cpp:99:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |         for(int i = 0; i< T[x].size() ; i++)
      |                        ~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from library.cpp:1:
library.cpp:104:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  104 |     assert(ans.size()>=n) ;
      |            ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 328 KB # of queries: 5049
2 Correct 62 ms 324 KB # of queries: 5009
3 Correct 73 ms 304 KB # of queries: 5309
4 Correct 76 ms 312 KB # of queries: 5317
5 Correct 66 ms 312 KB # of queries: 5349
6 Correct 80 ms 324 KB # of queries: 5357
7 Correct 70 ms 308 KB # of queries: 5397
8 Correct 77 ms 324 KB # of queries: 5073
9 Correct 58 ms 324 KB # of queries: 5285
10 Correct 48 ms 312 KB # of queries: 3085
11 Runtime error 1 ms 464 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 328 KB # of queries: 5049
2 Correct 62 ms 324 KB # of queries: 5009
3 Correct 73 ms 304 KB # of queries: 5309
4 Correct 76 ms 312 KB # of queries: 5317
5 Correct 66 ms 312 KB # of queries: 5349
6 Correct 80 ms 324 KB # of queries: 5357
7 Correct 70 ms 308 KB # of queries: 5397
8 Correct 77 ms 324 KB # of queries: 5073
9 Correct 58 ms 324 KB # of queries: 5285
10 Correct 48 ms 312 KB # of queries: 3085
11 Runtime error 1 ms 464 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -