답안 #714297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714297 2023-03-24T08:11:23 Z vjudge1 Art Collections (BOI22_art) C++17
20 / 100
120 ms 308 KB
#include <bits/stdc++.h>
#include "art.h"
using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) \
                    cout << v[i] << " "; \
                    cout<<endl;
struct DSU {
	vector<int> e;

	void init(int n)
	{
	    e.assign(n, -1);
	}

	int get(int x)
	{
	    if (e[x] < 0)
            return x;
        return get(e[x]);
	}

	bool together(int a, int b)
	{
	    if (get(a) == get(b))
            return true;
        return false;
	}

	int s(int x)
	{
	    return -e[get(x)];
	}

	bool un(int x, int y)
	{
		x = get(x);
        y = get(y);

		if (x == y) return false;

		if (e[x] > e[y]) swap(x, y);

		e[x] += e[y];
		e[y] = x;

		return true;
	}
};
vector<int> adj[41];
vector<int> s(41, 0);
vector<int> ans;
vector<int> indeg(41, 0);
int dfs1(int a)
{
    s[a] = 1;

    int temp = 0;

    for (int i = 0; i < adj[a].size(); i++)
    {
        if (s[adj[a][i]]) temp = max(temp, s[adj[a][i]]);
        else temp = max(temp, dfs1(adj[a][i]));
    }
    s[a] += temp;

    return s[a];
}

void dfs(int a)
{
    ans.pb(a);
    for (int i = 0; i < adj[a].size(); i++)
    {
        if (s[adj[a][i]] == s[a] - 1)
        {
            dfs(adj[a][i]);
        }
    }
}
void solve(int n)
{
    vector<int> v;
    for (int i = 1; i <= n; i++)
    {
        v.pb(i);
    }

    for (int i = 1; i <= n; i++)
    {
        swap(v[0], v[i - 1]);
        int x = publish(v);
        for (int j = i + 1; j <= n; j++)
        {
            swap(v[0], v[j - 1]);
            int y = publish(v);
            swap(v[0], v[j - 1]);

            if (y < x)
            {
                adj[j].pb(i);
                indeg[i]++;
            }
            else if (x < y)
            {
                adj[i].pb(j);
                indeg[j]++;
            }
        }
        swap(v[0], v[i - 1]);
    }
    int root;
    for (int i = 1; i <= n; i++)
    {
        if (!indeg[i])
        {
            root = i;
        }
    }
    dfs1(root);
    dfs(root);
    answer(ans);
}

Compilation message

art.cpp: In function 'int dfs1(int)':
art.cpp:77:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     for (int i = 0; i < adj[a].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
art.cpp: In function 'void dfs(int)':
art.cpp:90:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |     for (int i = 0; i < adj[a].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
art.cpp: In function 'void solve(int)':
art.cpp:138:8: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
  138 |     dfs(root);
      |     ~~~^~~~~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 12 ms 304 KB Output is correct
10 Correct 13 ms 292 KB Output is correct
11 Correct 10 ms 208 KB Output is correct
12 Correct 10 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 11 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 12 ms 304 KB Output is correct
10 Correct 13 ms 292 KB Output is correct
11 Correct 10 ms 208 KB Output is correct
12 Correct 10 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 11 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 13 ms 292 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 11 ms 308 KB Output is correct
25 Correct 9 ms 304 KB Output is correct
26 Incorrect 120 ms 300 KB Not correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 12 ms 304 KB Output is correct
10 Correct 13 ms 292 KB Output is correct
11 Correct 10 ms 208 KB Output is correct
12 Correct 10 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 11 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 13 ms 292 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 11 ms 308 KB Output is correct
25 Correct 9 ms 304 KB Output is correct
26 Incorrect 120 ms 300 KB Not correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 12 ms 304 KB Output is correct
10 Correct 13 ms 292 KB Output is correct
11 Correct 10 ms 208 KB Output is correct
12 Correct 10 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 11 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 13 ms 292 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 11 ms 308 KB Output is correct
25 Correct 9 ms 304 KB Output is correct
26 Incorrect 120 ms 300 KB Not correct
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 12 ms 304 KB Output is correct
10 Correct 13 ms 292 KB Output is correct
11 Correct 10 ms 208 KB Output is correct
12 Correct 10 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 9 ms 304 KB Output is correct
20 Correct 11 ms 308 KB Output is correct
21 Correct 1 ms 208 KB Output is correct
22 Correct 13 ms 292 KB Output is correct
23 Correct 11 ms 208 KB Output is correct
24 Correct 11 ms 308 KB Output is correct
25 Correct 9 ms 304 KB Output is correct
26 Incorrect 120 ms 300 KB Not correct
27 Halted 0 ms 0 KB -