output stringlengths 52 181k | instruction stringlengths 296 182k |
|---|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m;
cin >> n >> m;
vector<pair<int, int>> v(m);
for (int i = 0; i < m; ++i) {
cin >> v[i].first >> v[i].second;
v[i].first--, v[i].second--;
if (v[i].first > v[i].second) swap(v[i].fi... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<int> a(n), b(n);
set<pair<int, int> > s;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--;
y--;
if (x > y) swap(x, y);
s.insert({x, y});
... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
map<int, int> s;
int main() {
int i, j, t, k, ma, x, n, y, ans;
scanf("%d%d", &n, &t);
for (i = 0; i < t; i++) {
scanf("%d%d", &j, &k);
if (j > k) {
s[j * 100001 + k] = 11;
} else
s[k * 100001 + j] = 11;
}
for (i = 1; i <= n; i++) {
for... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
vector<string> v;
stringstream ss(s);
string x;
while (getline(ss, x, c)) v.emplace_back(x);
return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>:... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
const long long int hell = (long long int)(1e18 + 100LL);
const double pi = acos(-1.0);
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t, i, j, k, m, n, x, y;
t = 1;
while (t--) {
long long int flag = 0, K;
cin >> n >> ... | ### Prompt
Generate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 50;
vector<long long> g[N];
long long a[N], b[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m;
cin >> n >> m;
if (m >= (n * (n - 1)) / 2) {
return cout << "NO\n", 0;
}
cout << "YES\n";
for ... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
int n, m, r1, r2, ansa, ansb, ct, w;
vector<int> v[100005];
bool b = false, hv[100005];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
scanf("%d%d", &r1, &r2);
v[r1].push_back(r2);
v[r2].push_back(r1);
}
for (int i = 1; i <= n; i++) {... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> g[N], par(N, 0), lvl(N, 0), vis(N, 0), chain, present(N, 0),
up(N, 0);
bool cmp(int x, int y) { return lvl[x] < lvl[y]; }
void dfs(int s, int p, int &fg) {
lvl[s] = lvl[p] + 1;
vis[s] = 1;
par[s] = p;
sort(g[s].begin(), g[s].en... | ### Prompt
Your task is to create a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> rec;
int main() {
int n, m, u, v, cnt, flag;
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; i++) {
scanf("%d %d", &u, &v);
if (u > v) swap(u, v);
rec.insert(make_pair(make_pair(u, v), 1));
}
if (n == 1) {
printf("NO\n");
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 15;
const int inf = 0x3f3f3f3f;
int ans[2][N];
inline pair<int, int> getPr(set<pair<int, int> >& st, int n) {
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (!st.count(make_pair(i, j))) {
return make_pair(i,... | ### Prompt
Please create a solution in Cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
void itval(istream_iterator<string> it) {}
template <typename T, typename... Args>
void itval(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
itval(++it, args...);
}
const long long int MOD = 1e9 + 7;
template <typename T>
inline voi... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const short INF = 1E9 + 5;
const short base = 1E9 + 7;
set<int> gr[maxn];
int main() {
int n, m;
cin >> n >> m;
if (n == 1) {
cout << "NO\n";
return 0;
}
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
x--, y--;
... | ### Prompt
Please formulate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double e = exp(1.0);
const double pi = acos(-1);
const double eps = 1e-6;
set<int> s[maxn];
int a[maxn], b[maxn];
int main() {
int n, m, l, r;
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 111;
int n, m;
vector<vector<int> > v;
int was[MAX], clr[MAX], dd = 1, deg[MAX];
int ans1[MAX], ans2[MAX], cnt[MAX], sz[MAX], comp[MAX];
void dfs(int ver, int cc) {
was[ver] = 1;
++sz[cc];
comp[ver] = cc;
for (auto to : v[ver]) {
if (!was[t... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int N = 550000;
int a[N], b[N];
vector<int> adj[N];
bool vis[N];
int main() {
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i =... | ### Prompt
Develop a solution in cpp to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const long long MIV = 1e+9 + 7;
int main() {
set<pair<int, int> > st;
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
if (a > b) {
int c = a;
a = b;
b = c;
}
st.insert(mak... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base ::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
if (m == n * (n - 1) / 2) {
cout << "NO\n";
return 0;
}
vector<vector<int>> g(n);
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
--x, --y;
... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 998244353;
const int N = 100000 + 7;
set<pair<int, int>> st;
int arr1[N], arr2[N];
void construct(int a, int b, int n) {
arr2[a] = 1;
arr2[b] = 1;
arr1[a] = 1;
arr1[b] = 2;
int cur = 3;
for (int i = 1; i <=... | ### Prompt
Generate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1.);
set<int> N[100005];
int a[100005];
int main() {
long long n, m;
int p, x, y;
cin >> n >> m;
for (int i = (0); i < (m); i++) {
cin >> x >> y;
N[x]... | ### Prompt
Construct a cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
long long used[100010];
long long a1[100010];
long long a2[100010];
set<pair<long long, long long>> s;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m;
cin >> n >> m;
for (long long i = 0; i < n; i++) {
a1[i] = a2[i] = i... | ### Prompt
Please formulate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
void printans(int a, int b, int n) {
printf("YES\n");
int s = 3;
for (int i = 1; i <= n; i++) {
if (i == a)
printf("1 ");
else if (i == b)
printf("2 ");
else
printf("%d ", s++);
}
printf("\n");
s = 3;
for (int i = 1; i <= n; i++) ... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
const long long MOD = 1000000000 + 7;
const long long MAXN = 100000 + 100;
int main() {
int n;
cin >> n;
int m;
cin >> m;
set<pair<int, int>> ps;
for (int i = 0; i < m; ++i) {
int a, b;
scanf("%d%d", &a, &b);
... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
pair<int, int> p[maxn];
pair<int, int> findpos() {
int a, b, c = 0;
pair<int, int> res;
for (a = 1; a <= n; a++)
for (b = a + 1; b <= n; b++)
if ((res = make_pair(a, b)) != p[++c]) return res;
}
int main() {
cin >> n >>... | ### Prompt
Create a solution in cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
int b[100010], c[100010];
vector<int> a[100010];
int main() {
int n, m;
while (cin >> n >> m) {
int x, y;
for (int i = 0; i < m; ++i) {
scanf("%d%d", &x, &y);
a[x].push_back(y);
a[y].push_back(x);
}
bool l = 0;
vector<int> v;
fo... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const int mn = 1e5 + 10;
bool vis[mn];
vector<int> v[mn];
int main() {
int n, m;
scanf("%d %d", &n, &m);
while (m--) {
int a, b;
scanf("%d %d", &a, &b);
if (a > b) swap(a, b);
v[a].push_back(b);
}
int s = -1, e = -1;
for (int i = 1; i <= n; i++) ... | ### Prompt
Please formulate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exponent, long long modulus);
long long choose(long long n, long long k);
long long inverse(long long a, long long m);
void build();
long long ncr(long long n, long long r);
vector<long long> fact(1000010);
bool comp(pair<long long... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
vector<int> v[100003];
int fv[100003];
int main() {
long long t, n, i, j = 0, k = 0, s = 0, okneg = 0, cnt = 0,
mx = -99999999999999LL, m, cur = 0, pz2, pz1, a, b,
vl1 = 1, ok = 0, sus = 1, jos = 1;
cin >> n >> k;
if (k == n *... | ### Prompt
Create a solution in Cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
set<pair<int, int> > a;
int cnt[N], ans1[N], ans2[N], hv[N];
int main() {
scanf("%d%d", &n, &m);
if (n == 1) {
puts("NO");
return 0;
}
if (n == 2) {
if (m)
puts("NO");
else {
puts("YES");
puts("1 2")... | ### Prompt
Please formulate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int64_t n, i, j, k, l, sum = 0, flag = 0, t, ans = 0, a[200005], b[200005], m;
vector<int64_t> v[200005];
void solve() {
cin >> n >> m;
for (int64_t i = 0; i < m; i++) {
cin >> j >> k;
v[j].pus... | ### Prompt
Generate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
const int maxm = 2e6 + 10;
int n, m, a[maxn], b[maxn];
map<pair<long long, long long>, bool> mp;
int main() {
cin >> n >> m;
for (int i... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> links[100005];
long long ans[100005];
int main() {
long long n, m;
cin >> n >> m;
for (long long i = 0; i < m; i++) {
cin >> links[i].first >> links[i].second;
if (links[i].first > links[i].second) {
swap(links[i].first, links[... | ### Prompt
Construct a cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int ma... | ### Prompt
Create a solution in cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
unsigned long long n, k, ans = 0, a, b, sl = 1, jjj, pr, napr, mmm[100001];
vector<long long> sys[100001];
vector<long long> v;
int main() {
ios::sync_with_stdio(false);
cin >> n >> k;
if (n == 1 or k >= n * (n - 1) / 2 or (n == 2 and k > 0)) {
cout << "NO\n";
... | ### Prompt
Generate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int aa[N * 2], bb[N * 2], ii[N * 2];
int main() {
int n, m;
cin >> m >> n;
if (n == (long long)m * (m - 1) / 2) {
cout << "NO\n";
return 0;
}
for (int i = 0; i < n; i++) {
cin >> aa[i] >> bb[i], aa[i]--, bb[i]--;
ii[i] = i;
... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
long long n, m;
cin >> n >> m;
vector<vector<int>> a(n + 1);
vector<int> b(n + 1);
for (int i = 0, u, v; i < m; ++i) {
cin >> u >> v;
a[u].push_back(v);
a[v].p... | ### Prompt
Please create a solution in cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, i, j, k, a, b, c;
cin >> n >> m;
vector<set<int>> s(n + 1);
for (i = 0; i < m; i++) {
cin >> a >> b;
s[a].insert(b);
s[b].insert(a);
}
if (m == n * (n - 1) / 2)
cout << "NO\n";
... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
vector<int> q[100010];
int vis[100010];
int main() {
int n, m, x, y;
scanf("%d%d", &n, &m);
if (n < 2)
printf("NO\n");
else {
for (int i = 1; i <= m; i++) {
scanf("%d%d", &x, &y);
q[x].push_back(y);
q[y].push_back(... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
const int N = 100010;
int a[N] = {}, b[N] = {};
set<pair<long long, long long> > st;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a ... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN], b[MAXN];
int ta[MAXN], tb[MAXN], vis[MAXN];
set<int> s[100005];
int main() {
int n, m;
cin >> n >> m;
if (n == 1) {
puts("NO");
return 0;
}
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
if (x > y)... | ### Prompt
In CPP, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
int n, m, first[100005], k;
pair<int, int> inp[100005], tmp;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; ++i) {
scanf("%d%d", &inp[i].first, &inp[i].second);
if (inp[i].first > inp[i].second) swap(inp[i].first, inp[i].second);
}
sort(inp + 1,... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> > adj(n, vector<int>());
set<pair<int, int> > s;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
x--;
y--;
if... | ### Prompt
Create a solution in CPP for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100005;
int n, m;
set<pair<int, int> > S;
int res1[Maxn], res2[Maxn];
void Print() {
printf("YES\n");
for (int i = 1; i <= n; i++) printf("%d%c", res1[i], i + 1 <= n ? ' ' : '\n');
for (int i = 1; i <= n; i++) printf("%d%c", res2[i], i + 1 <= n ? ' ' ... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> e[100005];
int v[100005];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d%d", &a, &b);
e[a].push_back(b);
e[b].push_back(a);
}
int ea = -1, eb = -1;
for (int i = 1; i <= n; i++) {
if (... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int n, m, a[MAX], b[MAX];
set<pair<int, int> > s;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
int a, b;
scanf("%d%d", &a, &b);
if (a > b) swap(a, b);
s.insert({a, b});
}
if (n == 1) {
printf("NO\n")... | ### Prompt
Develop a solution in CPP to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
int n, m, b[100004];
pint a[100004];
int main() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i].first >> a[i].second;
if (a[i].first > a[i].second) swap(a[i].first, a[i].second);
}
sort(a, a + m);
if (m == n * (n - 1... | ### Prompt
Please create a solution in cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const double PI = 3.14159265359;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
if (m == (long long)n * (n - 1) / 2) {
cout << "NO";
return 0;
}
vector<vector<int>> v(n + 1);
for (int i = 0; i... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7, M = 2e6;
const long long mod = 1e9 + 7;
inline int read() {
int ret = 0;
char ch = getchar();
bool f = 1;
for (; !isdigit(ch); ch = getchar()) f ^= !(ch ^ '-');
for (; isdigit(ch); ch = getchar()) ret = (ret << 1) + (ret << 3) + ch - 48;
r... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<int> aa[100005];
bool fl[100005] = {0};
int main() {
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= m; ++i) {
int u, v;
scanf("%d%d", &u, &v);
aa[u].push_back(v);
aa[v].push_back(u);
}
if (m == n * (n - 1) / 2 || n == 1) {
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MAXN = 1e5 + 3;
int n, m, a[MAXN];
pair<int, int> p;
vector<int> g[MAXN];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t1, t2;
cin >> n >> m;
for (int i = 0; i < (int)(m); i++) {
cin >> t1 >> t2... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 100005;
long long n, m;
long long ans[MAX] = {};
pair<long long, long long> comp[MAX] = {};
int main(void) {
cin >> n >> m;
for (long long i0 = 0; i0 < m; i0++) {
cin >> comp[i0].first >> comp[i0].second;
if (comp[i0].first > comp[i0].secon... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
cout << x << endl;
exit(0);
}
const int maxn = 1e6 + 7;
int n;
int m;
set<pair<int, int>> have;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int a... | ### Prompt
Create a solution in cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
long long m, n, i, j, k, a, b;
pair<long long, long long> mass[2000005];
map<int, int> mymap[2000001];
int main() {
cin >> n >> m;
if (n == 1) {
cout << "NO";
return 0;
}
if (m >= (n * (n - 1)) / 2) {
cout << "NO";
return 0;
}
cout << "YES" << en... | ### Prompt
Your challenge is to write a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
const long long N = 1e5 + 1;
set<long long> q[N];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m;
cin >> n >> m;
while (m--) {
long long l, r;
cin >> l >> r;
q[l].insert(r);
q[r].i... | ### Prompt
Please provide a CPP coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
void fileio() {}
vector<vector<long long int>> g;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
fileio();
long long int n, m;
cin >> n >> m;
if (m >= n * (n - 1) / 2) {
cout << "NO";
return 0;
}
vector<long long int> a(n, 0), b(n,... | ### Prompt
Create a solution in CPP for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using ii = pair<ll, ll>;
using iii = pair<int, ii>;
using vii = vector<ii>;
using vvii = vector<vii>;
using vs = vector<string>;
int pasos;
int llarg;
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
... | ### Prompt
Construct a Cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
scanf("%d%d", &n, &m);
vector<vector<int> > v(n + 1);
for (int i = 0; i < m; i++) {
int e1, e2;
scanf("%d%d", &e1, &e2);
v[min(e1, e2)].push_back(max(e1, e2));
}
bool is = false;
int cur;
for (int i = 1; i < n; i++) {
i... | ### Prompt
Construct a cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long mod = 998244353;
inline long long add(long long a, long long b) {
a += b;
if (a >= mod) a -= mod;
return a;
}
inline long long sub(long long a, long long... | ### Prompt
Create a solution in Cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
long long on_bit(long long x, int pos) {
x |= (1ll << pos);
return x;
}
int off_bit(int x, int pos) {
x &= ~(1 << pos);
return x;
}
bool is_on_bit(long long x, int pos) { return ((x & (1ll << pos)) != 0); }
int flip_bit(int x, int pos) {
x ^= (1 << pos);
return ... | ### Prompt
Develop a solution in cpp to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
bool used[100005];
vector<int> adj[100005];
signed main() {
int n;
cin >> n;
if (n == 1 || n == 2) {
int k;
cin >> k;
if (n == 2 && k == 0) {
cout << "YES\n1 2\n1 1";
} else
cout << "NO";
return 0;
} else {
... | ### Prompt
In cpp, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
const int SI = 1e5 + 100;
long long n, m;
vector<int> G[SI];
int ans1[SI];
int ans2[SI];
bool vis[SI];
int main() {
scanf("%I64d %I64d", &n, &m);
for (int i = 1; i <= m; i++) {
int f, t;
scanf("%d %d", &f, &t);
if (f > t) swap(f, t);
G[f].push_back(t);
... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
if (n * (n - 1) / 2 <= m) {
cout << "NO";
return 0;
}
vector<pair<int, int>> pr;
for (int i = 0; i < m; ++i) {
int ai, bi;
cin >> ai >> bi;
ai--;
bi--;
pr.push_back({ai, bi});
pr.push_back({bi... | ### Prompt
Please create a solution in Cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
long long int n, m, x, y, A[100005], B[100005], say = 3;
map<pair<long long int, long long int>, long long int> tp;
int main() {
scanf("%lld %lld", &n, &m);
if (n < 2) {
printf("NO\n");
return 0;
};
if (n * (n - 1) / 2 == m) {
printf("NO\n");
return ... | ### Prompt
Please formulate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
vector<long long> v[100001];
bool compare(pair<long long, long long> x, pair<long long, long long> y) {
if (x.first < y.first) retur... | ### Prompt
Please formulate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
if (a > b)
return a;
else
return b;
}
long long int min(long long int a, long long int b) {
if (a < b)
return a;
else
return b;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
... | ### Prompt
Please create a solution in Cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
signed main() {
long long n, m;
cin >> n >> m;
long long a[n];
for (long long i = 2; i < n; i++) a[i] = i + 1;
vector<long long> b[n];
for (long long i = 0; i < m; i++) {
long long x, y;
cin >> x >> y;
x--;
y--;
... | ### Prompt
Construct a CPP code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
std::cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
std::cerr... | ### Prompt
Develop a solution in cpp to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
vector<int> V[N];
int sol1[N], sol2[N];
int n, m, a, b, cnt1 = 1, cnt2 = 2, st = 1, ok = 0;
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; i++) {
scanf("%d %d", &a, &b);
V[a].push_back(b);
V[b].push_back(a);
}
int cur... | ### Prompt
In Cpp, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 10;
long long bPow(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) {
res = (res * a) % mod;
}
b >>= 1;
a = (a * a) % mod;
}
re... | ### Prompt
Construct a cpp code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
set<pair<int, int>> blocked;
int main() {
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
a -= 1;
b -= 1;
blocked.insert(make_pair(a, b));
blocked.insert(make_pair(b, a));
}
if (n * (n - 1) == blocked.size()) {... | ### Prompt
Create a solution in cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
vector<set<int>> cmp(n);
for (int x, y; m--;) {
cin >> x >> y;
cmp[--x].insert(--y);
cmp[y].insert(x);
}
int x = -1, y;
for (int i = 0; i < n; ++i)
if (cmp[i].siz... | ### Prompt
Please provide a Cpp coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<int> graph[1001000];
int a[1001000];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) graph[i].push_back(i);
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
graph[a].push_b... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
set<pair<int, int>> s;
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
if (x > y) swap(x, y);
... | ### Prompt
Generate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<set<int>> a(n);
for (int i = 0; i < m; i++) {
int q, w;
cin >> q >> w;
a[q - 1].insert(w - 1);
a[w - 1].insert(q - 1);
}
for (int i = 0; i < n; i++) {
if (a[i].size() != (n - 1)) {
int ctr = ... | ### Prompt
In CPP, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, a[100100], in[100100], flag2, ans[100100];
map<int, int> mp[100100];
int main() {
scanf("%d%d", &n, &m);
if (n <= 500 && m == n * (n - 1) / 2) {
printf("NO\n");
return 0;
}
int u, v;
for (int i = 1; i <= m; i++) {
scanf("%d%d", &u, &v);
... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
const long long INF = 2000000005;
const long long BIG_INF = 2000000000000000005;
const long long mod = 1000000007;
const long long P = 31;
const long double PI = 3.141592653589793238462643;
const double eps = 1e-9;
using namespace std;
vector<pair<long long, long long> > dir = {{-1, 0}, {0, 1},... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m, arr[maxn], nxt = 1;
vector<int> adj[maxn];
void no() {
cout << "NO\n";
exit(0);
}
int main() {
ios_base::sync_with_stdio(false)... | ### Prompt
Generate a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100000];
int a[100000];
bool chk[100000];
int main() {
int N, M;
scanf("%d %d", &N, &M);
for (int i = 0, u, v; i < M; i++) {
scanf("%d %d", &u, &v);
--u;
--v;
adj[u].push_back(v);
adj[v].push_back(u);
}
int u = -1, v = -1;
for... | ### Prompt
In Cpp, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
map<pair<int, int>, bool> has;
int net[100500], d[100500];
void solve() {
scanf("%d %d", &n, &m);
if (m == (n * (n - 1)) >> 1) {
cout << "NO";
return;
}
for (int i = 1; i <= m; i++) {
int a, b;
scanf("%d %d", &a, &b);
if (a > b) swap(a,... | ### Prompt
Your challenge is to write a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int p[100005], d[100005];
bool vis[100005];
int head[100005], cnt;
struct edge {
int to, next;
} e[100005 << 1];
void addedge(int u, int v) {
e[++cnt].to = v;
e[cnt].next = head[u];
head[u] = cnt;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i... | ### Prompt
In Cpp, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
vector<int> G[N];
inline void work() {
int flag = 0, n, m;
scanf("%d%d", &n, &m);
while (m--) {
int u, v;
scanf("%d%d", &u, &v);
G[u].push_back(v), G[v].push_back(u);
}
int k = 2;
for (int i = 1; i <= n; i++)
if ... | ### Prompt
In CPP, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
const int maxe = 100000 + 5;
const int maxv = 5000 + 5;
const int mod = 1000000;
const int maxn = 2 * 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
int n, m, d, e;
long long t;
vector<int> a[maxn];
bool vis[maxn];
int main() {
cin >> n >> m;
if (n =... | ### Prompt
Your task is to create a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &item) {
out << '(' << item.first << ", " << ite... | ### Prompt
In CPP, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
pair<int, int> pos;
map<int, bool> mp[100010];
int main() {
int n, m, a, b;
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d %d", &a, &b);
if (a > b) swap(a, b);
mp[a][b] = 1;
}
if (1ll * n * (n - 1) / 2 <= 1ll * m) {
printf("NO\n");... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
int p1[100001] = {0};
int p2[100001] = {0};
set<int> s[100100];
int main() {
int n, m;
cin >> n >> m;
int a, b;
for (int i = 0; i < m; i++) {
scanf("%d%d", &a, &b);
if (a > b) swap(a, b);
s[a].insert(b);
}
for (int i = 1; i <= n; i++) {
for (int ... | ### Prompt
Please create a solution in cpp to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
const long long INF = 2 * 1e9;
using namespace std;
map<pair<long long, long long>, bool> used;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n, m;
cin >> n >> m;
if (n < 2 || m >= (n * (n - 1)) / 2) {
cout << "NO";
return 0;
}
vector<pair<long lo... | ### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int mul(long long int a, long long int b) {
return ((a % mod) * (b % mod)) % mod;
}
long long int add(long long int a, long long int b) {
return ((a % mod) + (b % mod)) % mod;
}
long long int sub(long long int a, long long int b) {... | ### Prompt
Generate a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
template <class T>
inline void sort(T &a) {
sort((a).begin(), (a).end());
}
template <class T>
inline void rsort(T &a) {
sort((a).rbegin(), (a).rend());
}
template <class T>
inline void reverse(T &a) {
reverse((a).begin(), (a... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
set<int> gr[100005];
int n, m;
bool flag[100005];
int ans[100005];
void go(int p1, int p2) {
printf("YES\n");
ans[p1] = 1;
ans[p2] = 1;
int j = 3, i;
for (i = 1; i <= n; i++) {
if (ans[i])
continue;
else {
ans[i] = j++;
}
}
for (i = 1; ... | ### Prompt
Your task is to create a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
bool ch[100005];
int main() {
int n, m;
cin >> n >> m;
if (n == 1) {
cout << "NO";
return 0;
}
while (m--) {
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
int a = 0, b = 0;
for (int i = 1; i <... | ### Prompt
Create a solution in Cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n... | ### Prompt
In CPP, your task is to solve the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compariso... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
pair<int, int> ans(-1, -1);
vector<pair<int, int> > v;
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
--x, --y;
v.emplace_back(min(x, y), max(x, y));
}
sort(v.... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
long long int p = 1000000007;
int main() {
long long int n, m;
cin >> n >> m;
pair<long long int, long long int> a[m + 1];
vector<long long int> adj[n + 1];
long long int ans1[n + 1], ans2[n + 1];
for (long long int i = 1; i <= m; i++) {
cin >> a[i].first >>... | ### Prompt
Your task is to create a cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
set<int> s[maxn];
int arr[maxn], brr[maxn];
void solve() {
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j)
if (s[i].count(j) == 0) {
arr[i] = 1, arr[j] = 2;
brr[i] = 1, brr[j] = 1;
int ... | ### Prompt
Generate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparisons ... |
#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
vector<int> edge[100005];
vector<int> oneWay[100005];
int deg[100005];
int deg2[100005];
bool used[100005];
i64 n, m;
bool visit[100005];
void dfs(int root) {
visit[root] = true;
for (aut... | ### Prompt
Construct a CPP code solution to the problem outlined:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the compari... |
#include <bits/stdc++.h>
using namespace std;
vector<int> vec[100004];
vector<pair<int, int> > temp;
int main() {
int a, b, ans[2][100004], j;
long long n, m;
scanf("%lld %lld", &n, &m);
for (int i = 0; i < m; ++i) {
scanf("%d %d", &a, &b);
vec[a].push_back(b);
vec[b].push_back(a);
}
if (m == (n... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long __gcd(long long a, long long b) {
if (b == 0) return a;
return __gcd(b, a % b);
}
vector<vector<int> > adj;
int main() {
std ::ios_base ::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
long long n, m;
cin >> n >> m;
a... | ### Prompt
Please formulate a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comp... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double e = exp(1.0);
const double pi = acos(-1);
const double eps = 1e-6;
set<int> s[maxn];
int a[maxn], b[maxn];
int main() {
int n, m, l, r;
... | ### Prompt
Please provide a cpp coded solution to the problem described below:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results o... |
#include <bits/stdc++.h>
using namespace std;
int vis[100005], vis1[100005];
vector<int> G[100005];
int main() {
int n, m, a, b;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) G[i].clear();
for (int i = 1; i <= m; i++)
scanf("%d%d", &a, &b), vis[a]++, vis[b]++, G[a].push_back(b),
G[b].push_back... | ### Prompt
Your task is to create a CPP solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
map<int, int> G[101000];
int n, m, a[101000];
int main() {
cin >> n >> m;
int u, v;
for (; m--;) {
scanf("%d%d", &u, &v);
G[u][v] = G[v][u] = 233;
}
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j)
if (!G[i].c... | ### Prompt
Create a solution in Cpp for the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of the comparison... |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 1e5 + 10;
int a[N];
vector<int> g[N];
int main() {
int n, m, u, v;
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; i++)
scanf("%d %d", &u, &v), g[u].push_back(v), g[v].push_back(... | ### Prompt
Your task is to create a Cpp solution to the following problem:
Vasya had an array of n integers, each element of the array was from 1 to n. He chose m pairs of different positions and wrote them down to a sheet of paper. Then Vasya compared the elements at these positions, and wrote down the results of th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.