#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) {
| ~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |