답안 #714254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
714254 2023-03-24T07:16:32 Z vjudge1 Art Collections (BOI22_art) C++17
0 / 100
0 ms 208 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> ans;

bool f(vector<int> v, vector<int> used, int &n)
{
    if (v.size() == n)
    {
        if (!publish(v))
        {
            ans = v;
            return true;
        }
        return false;
    }
    for (int i = 1; i <= n; i++)
    {
        if (!used[i])
        {
            v.pb(i);
            used[i] = true;
            if (f(v, used, n)) return true;
            used[i] = false;
            v.pop_back();
        }
    }
}

void solve(int n)
{
    vector<int> used(n+1, 0);
    vector<int> v;
    for (int i = 1; i <= n; i++)
    {
        v.pb(i);
    }
    f(v, used, n);
    answer(ans);
}

Compilation message

art.cpp: In function 'bool f(std::vector<int>, std::vector<int>, int&)':
art.cpp:73:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |     if (v.size() == n)
      |         ~~~~~~~~~^~~~
art.cpp:93:1: warning: control reaches end of non-void function [-Wreturn-type]
   93 | }
      | ^
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 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Not correct
2 Halted 0 ms 0 KB -