Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int V = 100 * 1000;
int n, m;
int ary[V + 1];
bool mark[V + 1];
vector<int> N[V + 1];
void read() {
ios_base ::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
N[u].push_back(v);
N[v].pus... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
cout << x << endl;
exit(0);
}
using ll = long long;
const int maxn = 1e6 + 5;
int n, m;
set<pair<int, int>> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
while (m--) {
int a,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
set<pair<int, int> > s;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
a--;
b--;
if (a > b) swap(a, b);
s.insert(pair<int, int>(a, b));
}
for (int i = 0; i < n; i++)... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > edg;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
a--;
b--;
edg.insert({a, b});
edg.insert({b, a});
}
if (n * (n - ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
long long mod(long long a, long long b) {
if (a > b)
return a - b;
else
return b - a;
}
long long power(long long x, long long y, long long p) {
long long res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long int, long long int>>> graph;
vector<long long int> max_fuel;
vector<bool> visit;
const long long int N = 1e5 + 7;
const long long int inf = 1e9 + 32;
long long int n, ans;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m;
set<int> e[101101];
int a[101101];
int main() {
scanf("%d%d", &n, &m);
if (m == 1LL * n * (n - 1) / 2) {
puts("NO");
return 0;
}
for (int i = 0; i < m; i++) {
int x, y;
scanf("%d%d", &x, &y);
e[x].insert(y);
e[y].insert(x);
}
in... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int mod2 = 998244353;
long long exp(long long taban, long long us, long long md) {
long long carpan = taban % md;
long long temp = us;
long long res = 1;
while (temp) {
if (temp % 2) res = (res * carpan) % md;
temp /= 2;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
vector<pair<long long int, long long int> > vp;
map<long long int, long long int> mp, mpp;
vector<long long int> v, v1, v2;
long long int dp[N], visit[N];
set<int> se[N];
template <typename Arg1>
void __f(const char* name, Arg... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
if (n == 1) {
cout << "NO";
return 0;
}
if (n < 1000) {
if ((n * (n - 1)) / 2 <= m) {
cout << "NO";
return 0;
}
}
vector<pair<int, int> > b(m);
vector<int> a(n);
int l, r;
for (int i = 0; ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | from sys import stdin
import operator as op
from bisect import *
from itertools import chain, repeat, starmap
from functools import reduce
class SortedList():
"""Sorted list is a sorted mutable sequence."""
DEFAULT_LOAD_FACTOR = 500
def __init__(self, iterable=None):
"""Initialize sorted list ins... | PYTHON |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
const int N = 1e5 + 5;
const long long int mod = 1e9 + 7;
const long long int Mod = 998244353;
const long double Pi = acos(-1);
const long long int Inf = 4e18;
const long double Eps = 1e-9;
int dx[9] = {0, 1, -1, 0, 0, 1, 1,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int num = 1e5 + 10;
int a[num], b[num];
struct node {
int u, v;
} e[num];
bool cmp(node &a, node &b) {
if (a.u == b.u)
return a.v < b.v;
else
return a.u < b.u;
}
int main() {
long long n, m;
scanf("%lld%lld", &n, &m);
for (int i = 1; i <= m; i++) {... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e5 + 15;
bool isAns = 1;
int n, m;
vector<vector<int>> gr;
vector<int> a, b;
void in() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
gr.resize(n + 5);
for (int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
gr[a]... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MX = (1 << 20);
vector<int> v[MX];
int n, m;
int depth[MX], ans1[MX];
bool shit[MX];
int timer;
int v1, v2;
void dfs(int x, int p) {
if (x != v1 && x != v2) ans1[x] = ++timer;
for (auto nxt : v[x]) {
if (depth[nxt] == 0) {
depth[nxt] = depth[x] + 1;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import java.io.*;
import java.util.*;
public class D1090
{
static boolean vis[];
static int val[];
public static void main(String args[])throws IOException
{
Reader sc=new Reader();
PrintWriter pw=new PrintWriter(System.out);
int n=sc.nextInt();
int m=sc.nextInt();
... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long 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 ma... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
set<int> s[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
if (n < 2) {
cout << "NO";
exit(0);
}
vector<pair<int, int>> v;
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m, a, b, p, t;
set<int> s[100010];
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> a >> b;
s[a].insert(b);
s[b].insert(a);
}
for (p = 1; p <= n; p++)
if (s[p].size() < n - 1) break;
if (p == n + 1) {
cout << "NO" << end... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
vector<int> g[N];
bool vis[N];
int pos, minn;
int a[N], b[N];
int cnt[N];
int main() {
memset(cnt, 0, sizeof(cnt));
memset(vis, false, sizeof(vis));
cin >> n >> m;
if (n == 1) {
cout << "NO" << endl;
return 0;
}
if (m ==... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int n, m;
vector<int> adl[MAXN];
int ans1[MAXN], ans2[MAXN];
queue<int> Q;
int main() {
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
int l, r;
scanf("%d %d", &l, &r);
adl[l].push_back(r);
adl[r].push_back(l);
}
if (n... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m;
int deg[100001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
if (m == (long long)n * (n - 1) / 2) {
printf("NO\n");
return 0;
}
set<pair<int, int> > sp;
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k;
const int N = 5e5 + 5;
int ans1[N], ans2[N];
set<int> v[N];
set<int> s;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (i = 1; i <= m; i++) {
int first, second;
cin >> first >> second;
v[first].... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
const long long MOD = 1e9 + 7, INF = 9e18;
const int inf = 2e9;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
V<set<int> > s(n + 1);
V<int> a1(n + 1), a2(n + 1);
while (m--) {
int a,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = 100009;
int n, m;
vector<int> a[MAX_N];
int c[MAX_N];
int main() {
cin >> n >> m;
if ((int64_t)n * (n - 1) / 2 == m) {
cout << "NO" << endl;
return 0;
}
cout << "YES" << endl;
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int in[N], a1[N], a2[N], v[N];
set<int> s[N];
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int x, y;
cin >> x >> y;
if (x > y) swap(x, y);
s[y].insert(x);
}
if (n == 1) {
cout << "NO" << endl;
r... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
set<pair<long long, long long> > second;
long long n, m, i;
cin >> n >> m;
long long a1[n];
long long a2[n];
for (auto i = 0; i < n; i++) {
a1[i] = -1;
a2[i] = -1;
}
for (auto i = 0; i... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > e;
int n, m;
int main() {
scanf("%d%d", &n, &m);
for (int _ = 0, ThxDem = m; _ < ThxDem; ++_) {
int x, y;
scanf("%d%d", &x, &y);
x--;
y--;
if (x > y) swap(x, y);
e.insert(make_pair(x, y));
}
if (m == n * (n - 1) / 2) {
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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});
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import sys
input=sys.stdin.buffer.readline
for _ in range(1):
n,m=map(int,input().split())
ans=[0]*(n+1)
a=[]
for i in range(m):
l,r=map(int,input().split())
if l>r:
l,r=r,l
a.append([l,r])
if m==int((n*(n-1))//2):
print("NO")
continue
a.sort(... | PYTHON3 |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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>:... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 >> ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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++) {... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
public static void main(String[] args) throws IOException {
PrintWriter out = new PrintWriter(System.out);
//Scanner sc = new Scanner();
Reader in = new Reader();
Main solver = new Main();
solver.... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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");
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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--;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 =... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | n, m = map(int, input().split())
c = [ [0, i, []] for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
c[a-1][0]+=1
c[a-1][2].append(b-1)
c[b-1][0]+=1
c[b-1][2].append(a-1)
if(n==1):
print("NO")
else:
ans = ((n*(n-1))//2)
if(m>=ans):
print("NO")
else:
c.sort(key = lambda x: x[0])
vall =... | PYTHON3 |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 <=... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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]... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | def read(type = 1):
if type:
file = open("input.dat", "r")
line = list(map(int, file.readline().split()))
n = line[0]
m = line[1]
a = []
for i in range(m):
line = tuple(map(int, file.readline().split()))
if line[0] < line[1]:
a.... | PYTHON3 |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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++) ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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);
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 >>... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.io.*;
public class Main{
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader inp = new InputReader(inputStream);
PrintWrite... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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++) ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;
/**... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 *... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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")... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import javax.swing.*;
import java.io.*;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public c... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | # ---------------------------iye ha aam zindegi---------------------------------------------
import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
# ------------------------------warmup------------------------... | PYTHON3 |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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[... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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";
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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;
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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";
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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(... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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)... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 ? ' ' ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | import javafx.util.Pair;
import java.io.*;
import java.util.HashSet;
import java.util.Set;
public class SimilarArrays {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new Buffere... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 (... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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")... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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) {
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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,... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 |
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.lang.System.*;
import static java.util.Arrays.*;
public class Main {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(System.ou... | JAVA |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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);
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 ... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 {
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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);
... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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... | CPP |
1090_D. Similar Arrays | 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 to another sheet of paper. For each pair he wrote either "great... | 2 | 10 | #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 ... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.