답안 #654401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654401 2022-10-31T08:43:20 Z Tuanlinh123 도서관 (JOI18_library) C++17
19 / 100
334 ms 436 KB
#include "library.h"
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

#define LOCALIO "C:/Users/admin/Documents/Code/"
#define maxn 1005

ll n;
vector <ll> ans[maxn];

ll calc(ll idx, ll l, ll r)
{
    ll q1=0, q2=0;
    vector <ll> m;
    m.assign(n, 0);
    for (ll i=l; i<=r; i++)
        m[i-1]=1;
    q1=Query(m);
    m[idx-1]=1;
    q2=Query(m);
    return q1+1-q2;
}

ll Find(ll idx, ll l, ll r)
{
    if (r<l)
        return 0;
    ll mid=(l+r)/2, q=calc(idx, l, r);
    if (q==0)
        return q;
    if (l==r && q==1)
    {
        ans[idx].pb(l);
        return q;
    }
    ll q1=Find(idx, l, mid);
    if (q>q1)
        Find(idx, mid+1, r);
    return q;
}

ll findstart()
{
    for (ll i=1; i<=n; i++)
        if (ans[i].size()==1)
            return i;
	return 0;
}

ll findnext(ll idx, ll prev)
{
    for (ll i=0; i<ans[idx].size(); i++)
        if (ans[idx][i]!=prev)
            return ans[idx][i];
    return -1;
}

void Solve(ll N)
{
	if (N==1)
	{
		vector <ll> res;
		res.pb(1);
		Answer(res);
		return;
	}
    n=N;
    for (ll i=1; i<=n; i++)
    {
        Find(i, 1, i-1);
        Find(i, i+1, n);
    }
    vector <ll> res;
    ll st=findstart();
    while (st!=-1)
    {
        res.pb(st);
        st=findnext(st, (res.size()==1 ? 0 : res[res.size()-2]));
    }
    Answer(res);
}

Compilation message

library.cpp: In function 'int findstart()':
library.cpp:52:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |     for (ll i=1; i<=n; i++)
      |     ^~~
library.cpp:55:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |  return 0;
      |  ^~~~~~
library.cpp: In function 'int findnext(int, int)':
library.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for (ll i=0; i<ans[idx].size(); i++)
      |                  ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 208 KB # of queries: 7922
2 Correct 118 ms 304 KB # of queries: 7944
3 Correct 96 ms 308 KB # of queries: 8340
4 Correct 128 ms 312 KB # of queries: 8330
5 Correct 103 ms 304 KB # of queries: 8434
6 Correct 111 ms 308 KB # of queries: 8270
7 Correct 73 ms 332 KB # of queries: 8428
8 Correct 119 ms 308 KB # of queries: 7962
9 Correct 80 ms 208 KB # of queries: 8394
10 Correct 64 ms 304 KB # of queries: 4906
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 4
13 Correct 1 ms 208 KB # of queries: 14
14 Correct 1 ms 208 KB # of queries: 32
15 Correct 4 ms 208 KB # of queries: 274
16 Correct 10 ms 208 KB # of queries: 668
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 208 KB # of queries: 7922
2 Correct 118 ms 304 KB # of queries: 7944
3 Correct 96 ms 308 KB # of queries: 8340
4 Correct 128 ms 312 KB # of queries: 8330
5 Correct 103 ms 304 KB # of queries: 8434
6 Correct 111 ms 308 KB # of queries: 8270
7 Correct 73 ms 332 KB # of queries: 8428
8 Correct 119 ms 308 KB # of queries: 7962
9 Correct 80 ms 208 KB # of queries: 8394
10 Correct 64 ms 304 KB # of queries: 4906
11 Correct 1 ms 208 KB # of queries: 0
12 Correct 0 ms 208 KB # of queries: 4
13 Correct 1 ms 208 KB # of queries: 14
14 Correct 1 ms 208 KB # of queries: 32
15 Correct 4 ms 208 KB # of queries: 274
16 Correct 10 ms 208 KB # of queries: 668
17 Runtime error 334 ms 436 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -