text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int x[60], y[60], n, r; void solve(int *x) { int t, w = 0; for (int i = (1); i <= (n); ++i) printf("("); for (int i = (1); i <= (n); ++i) { int t = (x[i] + 1) / 2; if (i > 1) putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", t, i - 1, i - 1); if (i > 1) putchar(')'); if (i != n) putchar('+'); } puts(""); } int main() { scanf("%d", &n); for (int i = (1); i <= (n); ++i) scanf("%d%d%d", &x[i], &y[i], &r); solve(x); solve(y); return 0; }
#include <bits/stdc++.h> using namespace std; int x[60], y[60], r; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r; for (int i = 0; i < n; i++) { if (i) printf("+"); else for (int j = 0; j < n - 1; j++) printf("("); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i, i); if (i) printf(")"); } printf("\n"); for (int i = 0; i < n; i++) { if (i) printf("+"); else for (int j = 0; j < n - 1; j++) printf("("); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i, i); if (i) printf(")"); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } const int maxn = 200001; int a[maxn], b[maxn]; int n, c[maxn]; char s[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &a[i], &b[i], &c[i]); } string fx = "0", fy = "0"; for (int i = 0; i <= n - 1; i++) { int d = a[i + 1]; sprintf(s, "(%d*((1-abs((t%+d)))+abs((abs((t%+d))-1))))", abs(d / 2), -i, -i); fx = "(" + fx + (d >= 0 ? "+" : "-") + s + ")"; d = b[i + 1]; sprintf(s, "(%d*((1-abs((t%+d)))+abs((abs((t%+d))-1))))", abs(d / 2), -i, -i); fy = "(" + fy + (d >= 0 ? "+" : "-") + s + ")"; } cout << fx << endl; cout << fy << endl; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1000; int x[maxn], y[maxn]; int ansx, ansy, kx, ky, zx, zy, n; string f, g; string ss(int a) { if (a == 0) return "0"; string s; while (a > 0) { s += a % 10 + '0'; a /= 10; } reverse(s.begin(), s.end()); return s; } int main() { cin >> n; for (int i = 0, r; i < n; i++) cin >> x[i] >> y[i] >> r; for (int i = 1; i < n; i++, f += '(', g += '(') ; f += ss(x[0]); g += ss(y[0]); ansx = x[0]; ansy = y[0]; kx = ky = 0; for (int i = 1; i < n; i++) { zx = (abs(x[i] - kx * i - ansx) / 2); zy = (abs(y[i] - ky * i - ansy) / 2); if (kx * i + ansx > x[i]) { f += "-(" + ss(zx) + "*(abs((t-" + ss(i - 1) + "))+(t-" + ss(i - 1) + "))))"; kx -= zx * 2; ansx += zx * (2 * i - 2); } else if (kx * i + ansx < x[i]) { f += "+(" + ss(zx) + "*(abs((t-" + ss(i - 1) + "))+(t-" + ss(i - 1) + "))))"; kx += zx * 2; ansx -= zx * (2 * i - 2); } else f += "+0)"; if (ky * i + ansy > y[i]) { g += "-(" + ss(zy) + "*(abs((t-" + ss(i - 1) + "))+(t-" + ss(i - 1) + "))))"; ky -= zy * 2; ansy += zy * (2 * i - 2); } else if (ky * i + ansy < y[i]) { g += "+(" + ss(zy) + "*(abs((t-" + ss(i - 1) + "))+(t-" + ss(i - 1) + "))))"; ky += zy * 2; ansy -= zy * (2 * i - 2); } else g += "+0)"; } cout << f << endl; cout << g << endl; }
#include <bits/stdc++.h> const int MAXN = 60; int n, r; int x[MAXN], y[MAXN]; void solve(int *x) { int t, w = 0; for (int i = 1; i <= n; ++i) putchar('('); for (int i = 1; i <= n; ++i) { int t = x[i] + 1 >> 1; if (i > 1) putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", t, i - 1, i - 1); if (i > 1) putchar(')'); if (i != n) putchar('+'); } puts(""); } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d%d", &x[i], &y[i], &r); solve(x), solve(y); return 0; }
#include <bits/stdc++.h> using namespace std; int x[60], y[60], r; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r; for (int i = 0; i < n; i++) { if (i) printf("+"); else for (int j = 0; j < n - 1; j++) printf("("); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i, i); if (i) printf(")"); } printf("\n"); for (int i = 0; i < n; i++) { if (i) printf("+"); else for (int j = 0; j < n - 1; j++) printf("("); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i, i); if (i) printf(")"); } return 0; }
#include <bits/stdc++.h> using namespace std; int x[500005], y[500005], z[500005]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d%d", x + i, y + i, z + i); } for (int i = 1; i < n; i++) { printf("("); } for (int i = 1; i <= n; i++) { if (i > 1) printf("+"); printf("("); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i - 1, i - 1); if (i > 1) printf(")"); } printf("\n"); for (int i = 1; i < n; i++) { printf("("); } for (int i = 1; i <= n; i++) { if (i > 1) printf("+"); printf("("); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i - 1, i - 1); if (i > 1) printf(")"); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; string ati(int i) { string s; s = "abs((t"; if (i < 0) { i = -i; s += "+"; } else s += "-"; s += to_string(i); s += "))"; return s; } int main() { int n; cin >> n; string f = "0"; string g = "0"; int x, y, r; for (int i = 0; i < n; i++) { cin >> x >> y >> r; if (x % 2) x++; if (y % 2) y++; f = "(" + f + "+" + "(" + to_string(x / 2) + "*((" + ati(i - 1) + "+" + ati(i + 1) + ")-(" + ati(i) + "+" + ati(i) + ")))" + ")"; g = "(" + g + "+" + "(" + to_string(y / 2) + "*((" + ati(i - 1) + "+" + ati(i + 1) + ")-(" + ati(i) + "+" + ati(i) + ")))" + ")"; } cout << f << endl << g; }
#include <bits/stdc++.h> using namespace std; string ans = ""; int f(int z, int x, int y) { return y / 2 * (1 - abs(z - x) + abs(abs(z - x) - 1)); } int n; int a[100][100]; string get(int k) { ans = ""; for (int i = 1; i < n; i++) ans += '('; for (int i = 0; i < n; i++) { int x, y; if (k == 0) y = a[i][1], x = a[i][0]; else y = a[i][0], x = a[i][1]; string tans = ""; int t = y / 2; bool z = t == 0; while (t != 0 || z) { z = 0; tans = char('0' + t % 10) + tans; t /= 10; } tans = '(' + tans + '*' + '('; string t1 = "(1-abs((t-", t2 = ")))+abs((abs((t-", t3 = "))-1))))"; if (i != 0) t3 += ')'; t3 += '+'; ans += tans; ans += t1; t = i; tans = ""; z = t == 0; while (t != 0 || z) { z = 0; tans = char('0' + t % 10) + tans; t /= 10; } ans += tans; ans += t2; ans += tans; ans += t3; } ans.resize(ans.size() - 1); return ans; } int main() { cin >> n; for (int i = 0; i < n; i++) { int x, y, r; cin >> x >> y >> r; a[i][0] = x, a[i][1] = y; } cout << get(1) << endl; cout << get(0); return 0; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; int total; char ans1[105] = {"abs((abs((abs((abs((abs((abs(((32+33)-abs(((t+t)-"}, ans2[105] = {"))))-32))-16))-8))-4))-2))-1"}; int x[105], y[105]; void work(int *a) { for (int i = 1; i < total; i++) printf("("); for (int i = 0; i < total; i++) { printf("((%s", ans1); printf("(%d+%d)", i, i); printf("%s)*(t", ans2); int k = a[i] / 2 - i; if (k >= 0) printf("+"); printf("%d)", k); printf(")"); if (i != 0) printf(")"); if (i < total - 1) printf("+"); } printf("\n"); } int main() { int k1 = 0; for (int i = 0; ans1[i]; i++) if (ans1[i] == '(') k1++; int k2 = 0; for (int i = 0; ans2[i]; i++) if (ans2[i] == ')') k2++; scanf("%d", &total); for (int i = 0; i < total; i++) { int r; scanf("%d%d%d", x + i, y + i, &r); } work(x); work(y); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pii = pair<int, int>; template <class T> inline bool Min(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool Max(T &a, T b) { return a < b ? (a = b, true) : false; } inline int ni() { int a; scanf("%d", &a); return a; } inline void pi(int a) { printf("%d", a); } inline ll nl() { ll a; scanf("%lld", &a); return a; } inline void pl(ll a) { printf("%lld", a); } inline double nd() { double a; scanf("%lf", &a); return a; } inline void pd(double a) { printf("%.8lf", a); } inline char nc() { char a; scanf("%c", &a); return a; } inline void pc(char a) { printf("%c", a); } inline void ps(string str) { printf("%s", str.c_str()); } inline void sp() { putchar(' '); } inline void endl() { putchar('\n'); } int n, t; int A[100], B[100]; void ans(int T[]) { printf("abs("); for (int i = 0; i < (int)(n - 1); ++i) printf("("); for (int i = 0; i < (int)(n); ++i) { printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", T[i] / 2, i, i); if (i > 0) printf(")"); if (i + 1 < n) printf("+"); } putchar(')'); endl(); } void solve() { n = ni(); for (int i = 0; i < (int)(n); ++i) A[i] = ni(), B[i] = ni(), t = ni(); ans(A); ans(B); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 55; int n, x[maxn], y[maxn], r[maxn]; void solve(int *x) { int t, w = 0; for (int i = 1; i <= n; i++) putchar('('); for (int i = 1; i <= n; i++) { int t = x[i] + 1 >> 1; if (i > 1) putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", t, i - 1, i - 1); if (i > 1) putchar(')'); if (i != n) putchar('+'); } puts(""); } int main() { cin >> n; for (int i = 1; i <= n; i++) scanf("%d%d%d", &x[i], &y[i], &r[i]); solve(x), solve(y); return 0; }
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; int x[105], y[105], r[105]; string vs[2]; void add(int id, int i, int x) { string str = "(((1-abs((t-"; str += to_string(i); str += ")))+abs((abs((t-"; str += to_string(i); str += "))-1)))*"; str += to_string(x); str += ")"; if (vs[id] == "") vs[id] = str; else { vs[id] = "(" + vs[id] + "+" + str + ")"; } } void fmain() { scanf("%d", &n); for (int(i) = 0; (i) < (int)(2); (i)++) vs[i] = ""; for (int(i) = 0; (i) < (int)(n); (i)++) { scanf("%d%d%d", x + i, y + i, r + i); add(0, i + 1, x[i] / 2); add(1, i + 1, y[i] / 2); } for (int(i) = 0; (i) < (int)(2); (i)++) cout << vs[i] << endl; } int main() { fmain(); return 0; }
#include <bits/stdc++.h> const int MAXN = 60; int n, r; int x[MAXN], y[MAXN]; void solve(int *x) { int t; for (int i = 1; i <= n; ++i) putchar('('); for (int i = 1; i <= n; ++i) { int t = x[i] + 1 >> 1; if (i > 1) putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", t, i - 1, i - 1); if (i > 1) putchar(')'); if (i != n) putchar('+'); } puts(""); } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d%d", &x[i], &y[i], &r); solve(x), solve(y); return 0; }
#include <bits/stdc++.h> using namespace std; string num(int x) { if (x > 50) return "(50+" + num(x - 50) + ")"; return to_string(x); } string pt(int t, int x) { string v = "(t-" + to_string(t) + ")"; return "(((abs((" + v + "-1))+abs((" + v + "+1)))-(abs(" + v + ")+abs(" + v + ")))*" + to_string(x / 2) + ")"; } string solve(vector<int> &arr) { string res = pt(0, arr[0]); for (int i = 1; i < arr.size(); i++) res = "(" + res + "+" + pt(i, arr[i]) + ")"; return res; } signed main() { std::ios::sync_with_stdio(false); cin.tie(0); int n, r; cin >> n; vector<int> x(n), y(n); for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r; cout << solve(x) << "\n" << solve(y) << "\n"; }
#include <bits/stdc++.h> const int N = 105; using namespace std; int n, x[N], y[N], r[N]; template <typename T> inline T read() { T x = 0, w = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * w; } int main() { n = read<int>(); for (int i = 1; i <= n; i++) x[i] = read<int>(), y[i] = read<int>(), r[i] = read<int>(); for (int i = 1; i < n; i++) putchar('('); for (int i = 1; i <= n; i++) { if (i >= 2) putchar('+'); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i, i); if (i >= 2) putchar(')'); } puts(""); for (int i = 1; i < n; i++) putchar('('); for (int i = 1; i <= n; i++) { if (i >= 2) putchar('+'); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i, i); if (i >= 2) putchar(')'); } puts(""); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int MAXN = 55; string add(string s, string t) { return "(" + s + "+" + t + ")"; } string subtr(string s, string t) { return "(" + s + "-" + t + ")"; } string mult(string s, string t) { return "(" + s + "*" + t + ")"; } string abs(string s) { return "abs(" + s + ")"; } string get0(int x) { stringstream ss; ss << x; return ss.str(); } string get(int x) { return x > 50 ? add("50", get(x - 50)) : get0(x); } int N; int X[MAXN], Y[MAXN]; string solve(int *arr) { string ans = "0"; for (int i = 1; i <= N; i++) { int val = arr[i]; string expr = subtr("t", get(i - 1)); expr = add(abs(expr), expr); expr = mult(get(abs(val) / 2), expr); if (val >= 0) { ans = add(ans, expr); } else { ans = subtr(ans, expr); } for (int j = i; j <= N; j++) { arr[j] -= (j - i + 1) * val; } } return ans; } int main() { if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); } cin >> N; for (int i = 1, tmp; i <= N; i++) { cin >> X[i] >> Y[i] >> tmp; X[i] -= X[i] % 2; Y[i] -= Y[i] % 2; } cout << solve(X) << endl << solve(Y) << endl; }
#include <bits/stdc++.h> using namespace std; void SR(int &x) { scanf("%d", &x); } void SR(long long &x) { scanf("%lld", &x); } void SR(double &x) { scanf("%lf", &x); } void SR(char *s) { scanf("%s", s); } void RI() {} template <typename I, typename... T> void RI(I &x, T &...tail) { SR(x); RI(tail...); } void SP(const int x) { printf("%d", x); } void SP(const long long x) { printf("%lld", x); } void SP(const double x) { printf("%.16lf", x); } void SP(const char *s) { printf(s); } void PS() { puts(""); } template <typename I, typename... T> void PS(I &x, T &...tail) { putchar(' '); SP(x); PS(tail...); } void PL() { puts(""); } template <typename I, typename... T> void PL(const I x, const T... tail) { SP(x); PS(tail...); } const int maxn = 52; int n; int a[maxn][2], r[maxn]; void read() { RI(n); for (int i = 0; i < int(n); i++) RI(a[i][0], a[i][1], r[i]); } char ans[maxn][2][1003]; void build() { for (int i = 0; i < int(n); i++) for (int j = 0; j < int(2); j++) a[i][j] -= a[i][j] % 2; for (int i = 0; i < int(n); i++) for (int j = 0; j < int(2); j++) { char *s = ans[i][j]; sprintf(s, "(%d*(2-abs((abs((t%+d))-abs((t%+d))))))", a[i][j] / 2, -i - 1, -i + 1); } } void print(int i, int j) { if (i == 0) printf(ans[i][j]); else { putchar('('); print(i - 1, j); putchar('+'); printf(ans[i][j]); putchar(')'); } } void sol() { print(n - 1, 0); PL(); print(n - 1, 1); PL(); } int main() { read(); build(); sol(); return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 55; int n, r, a[M], b[M]; void print(int i, int j) { cout << "(" << i / 2 << "*((1-abs((t-" << j << ")))+abs((1-abs((t-" << j << "))))))"; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i] >> r; if (i) cout << "("; } for (int i = 0; i < n; i++) { if (i) cout << "+"; print(a[i], i); if (i) cout << ")"; } cout << endl; for (int i = 1; i < n; i++) cout << "("; for (int i = 0; i < n; i++) { if (i) cout << "+"; print(b[i], i); if (i) cout << ")"; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n; int x[50], y[50]; void print(int i, bool isx) { int v; if (isx) { v = x[i] / 2; } else { v = y[i] / 2; } printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", v, i, i); } void print_sum(int i, bool isx) { if (i == n - 1) { print(i, isx); } else { cout << "("; print(i, isx); cout << "+"; print_sum(i + 1, isx); cout << ")"; } } int main() { cin >> n; int r; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> r; } if (n == 1) { cout << x[0] << endl << y[0]; } else { print_sum(0, true); cout << endl; print_sum(0, false); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int n; vector<int> X, Y, R; int main() { cin >> n; X.resize(n); Y.resize(n); R.resize(n); for (int i = 0; i < (int)n; i++) { cin >> X[i] >> Y[i] >> R[i]; } for (int i = 0; i < (int)n; i++) { if (i == 0) { for (int j = 1; j < (int)n; j++) cout << "("; } if (i > 0) cout << "+"; cout << "("; cout << X[i] / 2; cout << "*((1-abs((t-"; cout << i; cout << ")))+abs((abs((t-"; cout << i; cout << "))-1))))"; if (i > 0) cout << ")"; } cout << endl; for (int i = 0; i < (int)n; i++) { if (i == 0) { for (int j = 1; j < (int)n; j++) cout << "("; } if (i > 0) cout << "+"; cout << "("; cout << Y[i] / 2; cout << "*((1-abs((t-"; cout << i; cout << ")))+abs((abs((t-"; cout << i; cout << "))-1))))"; if (i > 0) cout << ")"; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 55; string s1, s2; int n; void adds(string& s, int x[], int id) { if (id == n) { s += "0"; return; } char buf[50], buf1[100]; sprintf(buf, "(1-abs((t-%d)))", id); sprintf(buf1, "(%d*(%s+abs(%s)))", x[id] / 2, buf, buf); s += "("; s += buf1; s += "+"; adds(s, x, id + 1); s += ")"; } int main() { int x[N], y[N]; cin >> n; for (int i = 0; i < n; ++i) { int r; cin >> x[i] >> y[i] >> r; } adds(s1, x, 0); adds(s2, y, 0); cout << s1 << "\n" << s2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 60; inline int rd() { int x = 0, w = 1; char ch = 0; while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return x * w; } int n, a[N][2]; int main() { n = rd(); for (int i = 1; i <= n; ++i) a[i][0] = rd() >> 1, a[i][1] = rd() >> 1, rd(); for (int i = 1; i < n; ++i) putchar('('); for (int i = 1; i <= n; ++i) { if (i > 1) putchar('+'); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", a[i][0], i - 1, i - 1); if (i > 1) putchar(')'); } putchar('\n'); for (int i = 1; i < n; ++i) putchar('('); for (int i = 1; i <= n; ++i) { if (i > 1) putchar('+'); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", a[i][1], i - 1, i - 1); if (i > 1) putchar(')'); } putchar('\n'); return 0; }
#include <bits/stdc++.h> using namespace std; string unko(int x) { stringstream ss; ss << x; return ss.str(); } string _unko(int x) { stringstream ss; if (x >= 0) ss << "+("; else ss << "-("; ss << abs(x); return ss.str(); } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> x(n), y(n), r(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> r[i]; x[i] = x[i] / 2 * 2; y[i] = y[i] / 2 * 2; } string f = unko(x[0]), g = unko(y[0]); int _dx = 0, _dy = 0; for (int i = 0; i + 1 < n; i++) { int dx = (x[i + 1] - x[i]) / 2, dy = (y[i + 1] - y[i]) / 2; string s = "*(abs((t-" + unko(i) + "))+(t-" + unko(i) + "))"; f = "(" + f + _unko(dx - _dx) + s + "))"; g = "(" + g + _unko(dy - _dy) + s + "))"; _dx = dx; _dy = dy; } cout << f << endl; cout << g << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 100; int n, x[maxn], y[maxn], r; void write(int x) { if (x <= 50) printf("%d", x); else { printf("(50+"); write(x - 50); printf(")"); } } void work() { for (int i = 1; i < n; i++) printf("("); for (int i = 1; i <= n; i++) { if (i > 1) printf("+"); printf("("); write(x[i]); printf("*((1-abs((t-"); write(i - 1); printf(")))+abs((abs((t-"); write(i - 1); printf("))-1))))"); if (i > 1) printf(")"); } printf("\n"); } int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d%d", x + i, y + i, &r); x[i] /= 2; y[i] /= 2; } work(); memcpy(x, y, sizeof(y)); work(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; stringstream ssx, ssy; for (int i = 0; i + 1 < n; i++) { ssx << "("; ssy << "("; } for (int i = 0; i < n; i++) { int x, y, r; cin >> x >> y >> r; ssx << "(" << x / 2 << "*((1-abs((t-" << i << ")))+abs((abs((t-" << i << "))-1))))" << (i > 0 ? ")" : "") << (i + 1 < n ? "+" : ""); ssy << "(" << y / 2 << "*((1-abs((t-" << i << ")))+abs((abs((t-" << i << "))-1))))" << (i > 0 ? ")" : "") << (i + 1 < n ? "+" : ""); } cout << ssx.str() << endl; cout << ssy.str() << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int N, x, y, r, dx, dy, A, B; string G("0"), T("0"), E(""); int main(void) { cin >> N; for (int i(0); i < N; ++i) cin >> x >> y >> r, x -= x & 1, y -= y & 1, dx = x - A, dy = y - B, A += dx, B += dy, G += (dx < 0 ? "-" : "+") + E + "(" + to_string(abs(dx / 2)) + "*((abs((t-" + to_string(i) + "))-abs((t-" + to_string(i + 1) + ")))+1))", T += (dy < 0 ? "-" : "+") + E + "(" + to_string(abs(dy / 2)) + "*((abs((t-" + to_string(i) + "))-abs((t-" + to_string(i + 1) + ")))+1))", G = "(" + G + ")", T = "(" + T + ")"; cout << G << endl << T << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void printfunc(vector<int> circs) { vector<string> ans; ans.push_back(to_string(circs[0])); int pos = circs[0]; int slope = 0; for (int i = 1; i < circs.size(); i++) { int diff = (circs[i] - pos - slope) / 2; slope += diff * 2; pos += slope; string a = "("; if (diff < 0) { a += "(0" + to_string(diff) + ")"; } else a += to_string(diff); a += "*(abs((t-" + to_string(i - 1) + "))+(t-" + to_string(i - 1) + ")))"; ans.push_back(a); } for (int i = 0; i < ans.size() - 1; i++) { cout << "("; } cout << ans[0] << "+"; for (int i = 1; i < ans.size() - 1; i++) { cout << ans[i] << ")+"; } cout << ans.back() << ")"; cout << endl; } int main() { int n; cin >> n; vector<int> x; vector<int> y; for (int i = 0; i < n; i++) { int a, b, r; cin >> a >> b >> r; x.push_back(a); y.push_back(b); } if (n == 1) { cout << x[0] << endl << y[0] << endl; return 0; } printfunc(x); printfunc(y); }
#include <bits/stdc++.h> using namespace std; const int N = 53; int x[N], y[N], r[N]; string a(string a, string b) { return "(" + a + "+" + b + ")"; } string m(string a, string b) { return "(" + a + "-" + b + ")"; } string mul(string a, string b) { return "(" + a + "*" + b + ")"; } string ab(string a) { return "abs(" + a + ")"; } string solve(int x[], int n) { string ret = ""; for (int i = 0; i < n; i++) { x[i] /= 2; string xsi = m("t", to_string(i)); string now = a(ab(a(xsi, "1")), m(ab(m(xsi, "1")), ab(a(xsi, xsi)))); now = mul(now, to_string(x[i])); if (ret == "") ret = now; else ret = a(ret, now); } return ret; } int main() { ios ::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i]; cout << solve(x, n) << '\n'; cout << solve(y, n) << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 55; int x[maxn], y[maxn], r[maxn]; void solve(int a[], int n) { for (int i = 1; i < n; i++) cout << "("; for (int i = 0; i < n; i++) { if (i) cout << "+"; cout << "(" << a[i] / 2 << "*((1-" << "abs((t-" << i << ")))+abs((abs((t-" << i << "))-1))))"; if (i) cout << ")"; } cout << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i]; solve(x, n); solve(y, n); return 0; }
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char ch; do { ch = getchar(); if (ch == '-') f = -1; } while (ch > '9' || ch < '0'); do { x = x * 10 + ch - '0'; ch = getchar(); } while (ch <= '9' && ch >= '0'); return f * x; } const int maxn = 55; int x[maxn], y[maxn], r[maxn]; int main() { string left = "(((1-abs((t-", mid = ")))+abs((abs((t-", right = "))-1)))"; string ans1 = ""; string ans2 = ""; int n = read(); for (int i = 0; i < n; i++) { x[i] = read(), y[i] = read(), r[i] = read(); } for (int i = 0; i < n - 1; i++) { ans1 += "("; ans2 += "("; } for (int i = 0; i < n; i++) { string num = to_string(i); ans1 += left + num + mid + num + right + "*" + to_string(x[i] / 2) + ")"; ans2 += left + num + mid + num + right + "*" + to_string(y[i] / 2) + ")"; if (i != 0) ans2 += ")", ans1 += ")"; if (i != n - 1) ans1 += "+", ans2 += "+"; } cout << ans1 << endl; cout << ans2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline void maz(T &a, T b) { if (a < b) a = b; } template <class T> inline void miz(T &a, T b) { if (a > b) a = b; } template <class T> inline T abs(T a) { return a > 0 ? a : -a; } const int N = 300100, INF = 1e9; const double EPS = 1e-6, MAGIC = 381401241.01201; int n, m; int A[N], B[N]; void output(int x, int t) { printf( "(" "%d*(" "((abs(((t-%d)+1))+abs(((t-%d)-1)))-abs((t-%d)))-abs((t-%d))" ")" ")", x / 2, t, t, t, t); } void make(int A[]) { for (int i = 0; i < n; i++) if (A[i] & 1) A[i]++; for (int i = 0; i < n - 1; i++) putchar('('); for (int i = 0; i < n; i++) { if (i != 0) putchar('+'); output(A[i], i); if (i != 0) putchar(')'); } puts(""); } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { int c; scanf("%d%d%d", &A[i], &B[i], &c); } make(A); make(B); }
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } const int maxn = 200001; int a[maxn], b[maxn]; int n, c[maxn]; char s[maxn]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &a[i], &b[i], &c[i]); if (a[i] & 1) a[i]--; if (b[i] & 1) b[i]--; } string fx = "0", fy = "0"; for (int i = 0; i <= n - 1; i++) { int d = a[i + 1] - a[i]; sprintf(s, "(%d*((abs((t%+d))-abs((t%+d)))+1))", abs(d / 2), -i, -i - 1); fx = "(" + fx + (d > 0 ? "+" : "-") + s + ")"; d = b[i + 1] - b[i]; sprintf(s, "(%d*((abs((t%+d))-abs((t%+d)))+1))", abs(d / 2), -i, -i - 1); fy = "(" + fy + (d > 0 ? "+" : "-") + s + ")"; } cout << fx << endl; cout << fy << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 55; pair<int, int> a[N]; int main() { int n; scanf("%d", &n); int r; for (int i = 0; i < n; ++i) { scanf("%d%d%d", &a[i].first, &a[i].second, &r); } string left = "(((1-abs((t-", mid = ")))+abs((abs((t-", right = "))-1)))"; string ans1 = ""; string ans2 = ""; for (int i = 0; i < n - 1; ++i) { ans1 += "("; ans2 += "("; } for (int i = 0; i < n; ++i) { string num = to_string(i); ans1 += left + num + mid + num + right + "*" + to_string(a[i].first / 2) + ")"; ans2 += left + num + mid + num + right + "*" + to_string(a[i].second / 2) + ")"; if (i != 0) ans1 += ")", ans2 += ")"; if (i != n - 1) ans1 += "+", ans2 += "+"; } cout << ans1 << endl; cout << ans2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 55; pair<int, int> a[N]; int main() { int n; scanf("%d", &n); int r; for (int i = 0; i < n; ++i) { scanf("%d%d%d", &a[i].first, &a[i].second, &r); } string left = "(((1-abs((t-", mid = ")))+abs((abs((t-", right = "))-1)))"; string ans1 = ""; string ans2 = ""; for (int i = 0; i < n - 1; ++i) { ans1 += "("; ans2 += "("; } for (int i = 0; i < n; ++i) { string num = to_string(i); ans1 += left + num + mid + num + right + "*" + to_string(a[i].first / 2) + ")"; ans2 += left + num + mid + num + right + "*" + to_string(a[i].second / 2) + ")"; if (i != 0) ans1 += ")", ans2 += ")"; if (i != n - 1) ans1 += "+", ans2 += "+"; } cout << ans1 << endl; cout << ans2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int Mx = 5e5 + 5; int x[Mx], y[Mx], z[Mx]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d%d%d", x + i, y + i, z + i); for (int i = 1; i < n; i++) putchar('('); for (int i = 1; i <= n; i++) { if (i > 1) putchar('+'); putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i - 1, i - 1); if (i > 1) putchar(')'); } puts(""); for (int i = 1; i < n; i++) printf("("); for (int i = 1; i <= n; i++) { if (i > 1) putchar('+'); putchar('('); printf("%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i - 1, i - 1); if (i > 1) putchar(')'); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; struct node { int x, y, r; } a[58]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].r); } for (int i = 1; i < n; i++) printf("("); for (int i = 1; i <= n; i++) { if (i > 1) printf("+"); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", a[i].x / 2, i - 1, i - 1); if (i > 1) printf(")"); } printf("\n"); for (int i = 1; i < n; i++) printf("("); for (int i = 1; i <= n; i++) { if (i > 1) printf("+"); printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", a[i].y / 2, i - 1, i - 1); if (i > 1) printf(")"); } return 0; }
#include <bits/stdc++.h> using namespace std; void solve(int x[55], int n) { for (int i = 1; i < n; ++i) printf("("); for (int i = 1; i <= n; ++i) { int k = x[i] / 2; printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", k, i, i); if (i != 1) printf(")"); if (i != n) printf("+"); } printf("\n"); } int main() { int n, i, x[55], y[55], r[55]; cin >> n; for (i = 1; i <= n; i++) scanf("%d%d%d", &x[i], &y[i], &r[i]); solve(x, n); solve(y, n); return 0; }
#include <bits/stdc++.h> int X[50], Y[50]; int n; std::string to_string(int x) { if (x == 0) return std::string("0"); std::string ret; while (x) { ret.push_back(x % 10 + '0'); x /= 10; } std::reverse(ret.begin(), ret.end()); return ret; } std::string work(int *X, int l, int r) { if (l == r) { return "(" + to_string(X[l] / 2) + "*((1-abs((t-" + to_string(l) + ")))+abs((abs((t-" + to_string(l) + "))-1))))"; } int mid = l + r >> 1; return "(" + work(X, l, mid) + "+" + work(X, mid + 1, r) + ")"; } int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d%d%*d", X + i, Y + i); } std::cout << work(X, 0, n - 1) << std::endl; std::cout << work(Y, 0, n - 1) << std::endl; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const int maxn = 1e6 + 10; int n, x[maxn], y[maxn], m; void solve1() { for (int i = 1; i < n; i++) cout << '('; for (int i = 0; i < n; i++) { if (i >= 1) cout << '+'; printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", x[i] / 2, i, i); if (i >= 1) cout << ')'; } } void solve2() { for (int i = 1; i < n; i++) cout << '('; for (int i = 0; i < n; i++) { if (i >= 1) cout << '+'; printf("(%d*((1-abs((t-%d)))+abs((abs((t-%d))-1))))", y[i] / 2, i, i); if (i >= 1) cout << ')'; } } int main() { cin >> n; for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> m; solve1(); cout << endl; solve2(); return 0; }
#include <bits/stdc++.h> using namespace std; int n; int X[55], Y[55], R[55]; void p(int* m, int i) { if (i + 1 < n) { cout << "("; } int temp = m[i] / 2; cout << "(" << temp << "*((1-abs((t-" << i << ")))+abs((abs((t-" << i << "))-1))))"; if (i + 1 < n) { cout << "+"; p(m, i + 1); cout << ")"; } } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> X[i] >> Y[i] >> R[i]; } p(X, 0); cout << endl; p(Y, 0); cout << endl; return 0; }
#include <bits/stdc++.h> const int MAX_N = (int)1e5 + 123; const double eps = 1e-6; const int inf = (int)1e9 + 123; using namespace std; string first, second; int n; string tostr(int x) { string now = (x > 0 ? "" : "0"); while (x) { now += char(x % 10 + '0'); x /= 10; } reverse(now.begin(), now.end()); return now; } int main() { cin >> n; for (int i = 1, x, y, R; i <= n; i++) { cin >> x >> y >> R; string a = "1"; string b = "abs((t-" + tostr(i) + "))"; string now = "((" + a + "-" + b + ")" + "+abs((" + a + "-" + b + ")))"; string l = "(" + tostr(x / 2) + "*" + now + ")"; string r = "(" + tostr(y / 2) + "*" + now + ")"; if (i == 1) { first = l, second = r; } else { first = "(" + first + "+" + l + ")"; second = "(" + second + "+" + r + ")"; } } cout << first << endl << second; return 0; }
#include <bits/stdc++.h> using namespace std; inline int read() { int a = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) { if (c == '-') f = 1; c = getchar(); } while (isdigit(c)) { a = (a << 3) + (a << 1) + (c ^ '0'); c = getchar(); } return f ? -a : a; } int point[51][3], N; void solve(int l, int r, int dir) { if (l == r) printf("(%01d*abs(((1-abs((t-%d)))+abs((abs((t-%d))-1)))))", point[l][dir] / 2, l, l); else { putchar('('); solve(l, l + r >> 1, dir); putchar('+'); solve((l + r >> 1) + 1, r, dir); putchar(')'); } } int main() { N = read(); for (int i = 1; i <= N; ++i) { point[i][0] = read(); point[i][1] = read(); point[i][2] = read(); } solve(1, N, 0); putchar('\n'); solve(1, N, 1); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; vector<int> mas(k, 0); for (int i = 0; i < n; i++) { int m; cin >> m; for (int i = 0; i < m; i++) { int x; cin >> x; mas[x - 1]++; } } for (int i = 0; i < k; i++) { if (mas[i] == 0) { cout << "NO"; return; } } cout << "YES"; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tst = 1; while (tst--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int xi; set<int> sw; for (int i = 0; i < n; i++) { cin >> xi; int yij; for (int j = 0; j < xi; j++) { cin >> yij; sw.insert(yij); } } if (sw.size() == m) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf(" %d %d ", &n, &m); vector<int> bulbs(m, 0); int b; for (int i = 0; i < n; i++) { int k; scanf(" %d ", &k); for (int j = 0; j < k; j++) { scanf(" %d ", &b); b--; bulbs[b] = 1; } } bool possivel = true; for (int i = 0; i < bulbs.size(); i++) { if (bulbs[i] == 0) possivel = false; } if (possivel) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; const long N = 1000000000; class bulbs { int n, m; set<int> set_b; public: void read() { int n1, b; cin >> n >> m; for (int i = 1; i <= n; i++) { scanf("%d", &n1); for (int j = 1; j <= n1; j++) { scanf("%d", &b); set_b.insert(b); } } } bool ans() { if (set_b.size() == m) return 1; else return 0; } }; int main() { bulbs bu; bu.read(); if (bu.ans()) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, x, y, t[1000000]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> y; t[y] = 1; } } for (int i = 1; i <= m; i++) { if (t[i] == 0) { cout << "NO"; return 0; } } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int mod = 1e9 + 7; const int N = 1e5 + 228; const double PI = acos(-1); const double eps = 1e-9; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; vector<bool> a(m + 1); for (int i = 0; i < n; i++) { int k; cin >> k; int x; while (k--) { cin >> x; a[x] = 1; } } for (int i = 1; i <= m; i++) { if (!a[i]) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y; set<int> s; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; for (int j = 1; j <= x; j++) { cin >> y; s.insert(y); } } if (s.size() == m) { cout << "YES\n"; } else { cout << "NO\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; bool arr[101] = {false}; int bulbsNumber, counter = 0; for (int i = 0; i < n; i++) { cin >> bulbsNumber; for (int j = 0; j < bulbsNumber; j++) { int bulb; cin >> bulb; if (!arr[bulb]) { counter++; arr[bulb] = true; } if (counter == m) { cout << "YES"; return 0; } } } cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m; int a[110]; int main() { memset(a, 0, sizeof(a)); cin >> n >> m; while (n--) { int k; cin >> k; while (k--) { int x; cin >> x; a[x] = 1; } } for (int i = 1; i <= m; ++i) { if (!a[i]) { puts("NO"); return 0; } } puts("YES"); return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, e, g, f, h, i, j, k, l, m, n; int x[101]; int y[101]; int main() { cin >> n >> m; for (i = 0; i < n; i++) { cin >> x[i]; for (j = 0; j < x[i]; j++) { cin >> a; y[a - 1]++; } } for (i = 0; i < m; i++) { if (y[i] == 0) { cout << "NO"; return 0; } } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; const int N = 2 + 1e5; const int MAXN = 1 + 5e4; const int INF = 0x3f3f3f3f; int n, m; int d[N]; int main() { cin >> n >> m; int kq = 0; for (int i = 0; i < n; i++) { int x; cin >> x; for (int j = 0; j < x; j++) { int y; cin >> y; d[y]++; if (d[y] == 1) kq++; } } if (kq == m) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; set<int> S; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a; for (int j = 0; j < a; j++) { cin >> b; S.insert(b); } } if (static_cast<int>(S.size()) == m) { cout << "YES" << endl; } else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { long long r; while (b != 0) { r = a % b; a = b; b = r; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long fpow(long long n, long long k, int p = (int)1e9 + 7) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; n = n * n % p; } return r; } const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = 2 * acos((long double)0); const int maxn = 110; int n, m; int a[maxn]; void solve() { scanf("%d%d", &n, &m); for (int i = (0); i < (n); i++) { int k; scanf("%d", &k); for (int i = (0); i < (k); i++) { int d; scanf("%d", &d); d--; a[d] = 1; } } for (int i = (0); i < (m); i++) if (!a[i]) { printf("NO"); return; } printf("YES"); } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { vector<int> g1; long long int n, m; cin >> n >> m; long long int i = 0; while (i < n) { long long int k; cin >> k; long long int j = 0; while (j < k) { long long int h; cin >> h; g1.push_back(h); j++; } i++; } sort(g1.begin(), g1.end()); g1.erase(unique(g1.begin(), g1.end()), g1.end()); if (g1.size() == m) { cout << "YES"; } else { cout << "NO"; } }
#include <bits/stdc++.h> using namespace std; int main() { bool a[100] = {}; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { int x; cin >> x; for (int j = 0; j < x; j++) { int y; cin >> y; a[y - 1] = true; } } for (int i = 0; i < m; i++) { if (!a[i]) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a[10001], i, j, k, p, n, m; cin >> n >> m; int c = 0; for (int t = 1; t <= n; t++) { cin >> p; for (i = 0; i < p; i++) { cin >> a[c]; c++; } } sort(a, a + c); k = 1; for (i = 0; i < c; i++) { if (a[i] == k) { k++; } } if (k - 1 == m) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int xx[4] = {0, 0, 1, -1}; int yy[4] = {-1, 1, 0, 0}; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int n, m; cin >> n >> m; vector<long long int> v(m, 0); while (n--) { int x; cin >> x; while (x--) { int k; cin >> k; v[k - 1]++; } } bool flag = true; for (long long int i = 0; i < m; i++) { if (v[i] <= 0) { flag = false; break; } } if (flag) cout << "YES" << "\n"; else cout << "NO" << "\n"; return 0; }
#include <bits/stdc++.h> const long long MAX = 1000001; const int mod = 1e9 + 7; const double pi1 = acos(-1.0); using namespace std; long long binpow(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) { res *= a; } a *= a; n >>= 1; } return res; } int m, n, num; bool bulbs[105]; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m; memset(bulbs, false, sizeof(bulbs)); for (int i = 0; i < n; i++) { cin >> num; int input; for (int j = 0; j < num; j++) { cin >> input; bulbs[input] = true; } } for (int i = 1; i <= m; i++) { if (!bulbs[i]) { cout << "NO\n"; return 0; } } cout << "YES\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m + 1]; memset(a, 0, sizeof(a)); for (int i = 0; i < n; i++) { int x; cin >> x; for (int j = 0; j < x; j++) { int y; cin >> y; a[y] = 1; } } for (int i = 1; i <= m; i++) if (a[i] == 0) { cout << "NO"; return 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int main() { int m, n, count = 0, x1, aux; scanf("%d %d", &n, &m); bool vet[101]; memset(vet, false, sizeof vet); for (int i = 0; i < n; i++) { scanf("%d", &x1); while (x1--) { scanf("%d", &aux); if (!vet[aux]) { vet[aux] = true; count++; } } } printf((count == m ? "YES" : "NO")); return 0; }
#include <bits/stdc++.h> int main() { int i, j, k, l, x, y, flag = 1, a[101] = {0}; scanf("%d%d", &i, &j); for (k = 1; k <= i; k++) { scanf("%d", &x); for (l = 0; l < x; l++) { scanf("%d", &y); a[y - 1] = 1; } } for (k = 0; k < j; k++) { if (a[k] == 0) flag = 0; } if (flag == 1) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int arrx[105]; int arr[105]; int temp1 = 0; int temp2 = 1; int counter1 = 0; int x; for (int j = 1; j <= m; j++) arr[j] = temp1; for (int i = 0; i < n; i++) { counter1 = 0; cin >> x; for (int k = 0; k < x; k++) { cin >> arrx[k]; arr[arrx[k]] = temp2; } } for (int k = 1; k <= m; k++) { if (arr[k] == temp2) counter1++; } if (counter1 == m) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<bool> visited(m + 1, 0); for (int i = 0; i < n; i++) { int x; cin >> x; for (int j = 0; j < x; j++) { int y; cin >> y; visited[y] = 1; } } for (int i = 1; i <= m; i++) if (!visited[i]) { cout << "NO"; return 0; } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, v; set<int> asd; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> v; asd.insert(v); } } if (asd.size() == m) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, k, m, x, F[105]; int main() { cin >> n >> k; while (n--) { cin >> m; while (m--) { cin >> x; F[x]++; } } bool ok = 1; for (int i = 1; i <= k; i++) if (F[i] == 0) ok = 0; if (ok) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { set<int> st; int n, m, x, t; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> t; st.insert(t); } } if (st.size() == m) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> arr(m, 0); while (n--) { int k; cin >> k; vector<int> ys(k); for (auto &y : ys) { cin >> y; arr[y - 1]++; } } for (auto &x : arr) { if (x <= 0) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> int main() { int n, m, i, x, flag = 0; int *bulbs, *final; scanf("%d %d", &n, &m); final = (int *)malloc(sizeof(int) * m); for (i = 0; i < m; i++) final[i] = 0; while (n > 0) { scanf("%d", &x); bulbs = (int *)malloc(sizeof(int) * x); for (i = 0; i < x; i++) { scanf("%d", &bulbs[i]); final[bulbs[i] - 1] = 1; } n--; free(bulbs); } for (i = 0; i < m; i++) if (final[i] == 0) { flag = 1; break; } if (flag == 0) printf("Yes"); else printf("No"); }
#include <bits/stdc++.h> using namespace std; int const N = 105; int n, m, mrk[N]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { int num; cin >> num; for (int j = 1; j <= num; j++) { int v; cin >> v; mrk[v] = 1; } } for (int i = 1; i <= m; i++) if (!mrk[i]) { cout << "NO"; return 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int a[500]; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { int x; scanf("%d", &x); for (int j = 1; j <= x; j++) { int y; scanf("%d", &y); a[y] = 1; } } int flag = 0; for (int i = 1; i <= m; i++) { if (a[i] == 0) flag = 1; } if (flag) return puts("NO"); else puts("YES"); }
#include <bits/stdc++.h> using namespace std; void test_case() {} int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; set<int> bulbs; for (int i = 0; i < n; i++) { int x; cin >> x; while (x--) { int a; cin >> a; bulbs.insert(a); } } if (bulbs.size() == m) { cout << "YES"; } else { cout << "NO"; } return 0; }
#include <bits/stdc++.h> using namespace std; bool u[101]; int main() { int n, m, k, t; cin >> m >> n; for (int i = 0; i < m; i++) { cin >> k; for (int j = 0; j < k; j++) { cin >> t; u[t] = 1; } } bool f = 1; for (int i = 1; i <= n; i++) { if (!u[i]) f = 0; } if (f) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 0; int main() { int button, light; int arr[105]; for (int i = 0; i < 105; i++) { arr[i] = 0; } cin >> button >> light; for (int i = 0; i < button; i++) { int x; cin >> x; for (int i = 0; i < x; i++) { int y; cin >> y; arr[y - 1]++; } } bool flag = true; for (int i = 0; i < light; i++) { if (arr[i] == 0) { flag = false; } } if (flag) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, arr[101] = {0}, y; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> y; arr[y] = 1; } } for (int i = 1; i <= m; i++) if (arr[i] == 0) { cout << "NO"; return 0; } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d%d", &n, &m); vector<int> v(m + 1, 0); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); for (int j = 0; j < x; j++) { int y; scanf("%d", &y); v[y] = 1; } } for (int i = 1; i <= m; i++) { if (v[i] == 0) { printf("NO"); return 0; } } printf("YES"); return 0; }
#include <bits/stdc++.h> using namespace std; long long a[1000001], n, m = INT_MIN, b[1000001], c, k1, c1, r, l, x, m1 = INT_MAX, p1, p, k, t, tx1 = -1, ty1 = -1, tx2 = -1, ty2 = -1, a1, b1, y, mid; bool u[1000001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; for (int j = 1; j <= x; j++) { cin >> y; u[y]++; } } for (int i = 1; i <= m; i++) { if (u[i] == 0) return cout << "NO", 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; set<int> v1; int main() { int b, c, i, p, j, x; cin >> b >> c; for (i = 1; i <= b; i++) { cin >> p; for (j = 1; j <= p; j++) { cin >> x; if (x <= c) v1.insert(x); } } if (v1.size() == c) cout << "YES\n"; else cout << "NO\n"; v1.clear(); }
#include <bits/stdc++.h> using namespace std; int main() { std::set<int> a; int m, n; cin >> n >> m; int i; int temp; int t1; for (i = 0; i < n; i++) { cin >> t1; for (int j = 0; j < t1; j++) { cin >> temp; a.insert(temp); } } if (m == a.size()) { cout << "YES"; } else { cout << "NO"; } }
#include <bits/stdc++.h> using namespace std; void reader(int *x) { int k, m = 0; *x = 0; for (;;) { (k) = getchar(); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { *x = k - '0'; break; } } for (;;) { (k) = getchar(); if (k < '0' || k > '9') break; *x = (*x) * 10 + k - '0'; } if (m) (*x) = -(*x); } void reader(long long *x) { int k, m = 0; *x = 0; for (;;) { (k) = getchar(); if (k == '-') { m = 1; break; } if ('0' <= k && k <= '9') { *x = k - '0'; break; } } for (;;) { (k) = getchar(); if (k < '0' || k > '9') break; *x = (*x) * 10 + k - '0'; } if (m) (*x) = -(*x); } void reader(double *x) { scanf("%lf", x); } int reader(char c[]) { int i, s = 0; for (;;) { (i) = getchar(); if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break; } c[s++] = i; for (;;) { (i) = getchar(); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c[s++] = i; } c[s] = '\0'; return s; } template <class T, class S> void reader(T *x, S *y) { reader(x); reader(y); } template <class T, class S, class U> void reader(T *x, S *y, U *z) { reader(x); reader(y); reader(z); } template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w) { reader(x); reader(y); reader(z); reader(w); } void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) putchar('-'); while (s--) putchar(f[s] + '0'); putchar(c); } void writer(long long x, char c) { int s = 0, m = 0; char f[20]; if (x < 0) m = 1, x = -x; while (x) f[s++] = x % 10, x /= 10; if (!s) f[s++] = 0; if (m) putchar('-'); while (s--) putchar(f[s] + '0'); putchar(c); } void writer(double x, char c) { printf("%.15f", x); putchar(c); } void writer(const char c[]) { int i; for (i = 0; c[i] != '\0'; i++) putchar(c[i]); } void writer(const char x[], char c) { int i; for (i = 0; x[i] != '\0'; i++) putchar(x[i]); putchar(c); } template <class T> void writerLn(T x) { writer(x, '\n'); } template <class T, class S> void writerLn(T x, S y) { writer(x, ' '); writer(y, '\n'); } template <class T, class S, class U> void writerLn(T x, S y, U z) { writer(x, ' '); writer(y, ' '); writer(z, '\n'); } template <class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; } for (i = 0; i < n - 1; i++) writer(x[i], ' '); writer(x[n - 1], '\n'); } char memarr[17000000]; void *mem = memarr; int N, M; int chk[1000]; int main() { int i, j, k; reader(&N, &M); while (N--) { reader(&k); while (k--) reader(&i), chk[i - 1] = 1; } for (i = 0; i < M; i++) if (!chk[i]) break; writerLn(i == M ? "YES" : "NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int arr[1010], n, m, k, i, j, in, res; int main() { scanf(" %d %d", &n, &m); res = 0; for (i = 1; i <= n; i++) { scanf(" %d", &k); for (j = 1; j <= k; j++) { scanf(" %d", &in); if (arr[in] == 0) { arr[in] = 1; res++; } } } if (res == m) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d", &n), scanf("%d", &m); int no, x; set<int> s; for (int i = 0; i < n; ++i) { scanf("%d", &no); for (int i = 0; i < no; ++i) { scanf("%d", &x); s.insert(x); } } int siz = (int)s.size(); if (siz == m) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, x, i, y; bool f[110]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); return x * f; } inline void write(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) write(x / 10); putchar(x % 10 + '0'); } int main() { m = read(); n = read(); for (i = 1; i <= m; i++) { x = read(); while (x) { x--; y = read(); f[y] = 1; } } for (i = 1; i <= n; i++) if (!f[i]) { puts("NO"); return 0; } puts("YES"); }
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); int buttons, bulbs; std::cin >> buttons >> bulbs; bool *on = new bool[bulbs]; for (int i = 0; i < bulbs; ++i) { on[i] = false; } for (int i = 0; i < buttons; ++i) { int temp; std::cin >> temp; for (int j = 0; j < temp; ++j) { int temp2; std::cin >> temp2; on[temp2 - 1] = true; } } for (int i = 0; i < bulbs; ++i) { if (!on[i]) { std::cout << "NO\n"; return 0; } } std::cout << "YES\n"; }
#include <bits/stdc++.h> using namespace std; bool ara[100001]; int main(int argc, char const *argv[]) { int n, m, num, bulb; cin >> n >> m; while (n--) { cin >> num; while (num--) { cin >> bulb; ara[bulb] = true; } } for (int i = 1; i <= m; i++) { if (!ara[i]) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> int main() { unsigned int buttons, bulbs, switches, b; std::cin >> buttons >> bulbs; std::set<unsigned int> numbers; for (unsigned int idx = 0; idx < buttons; idx++) { std::cin >> switches; for (unsigned int jdx = 0; jdx < switches; jdx++) { std::cin >> b; numbers.insert(b); } } if (numbers.size() == bulbs) std::cout << "YES" << std::endl; else std::cout << "NO" << std::endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int m; cin >> m; set<int> q; for (int i = 0; i < n; ++i) { int k; cin >> k; for (int j = 0; j < k; ++j) { int x; cin >> x; q.insert(x); } } cout << ((q.size() == m) ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int N, M, s[105]; int main() { scanf("%d %d", &N, &M); for (int i = 1; i <= (N); i++) { int x; scanf("%d", &x); for (int j = 1; j <= (x); j++) { int y; scanf("%d", &y); s[y] = 1; } } for (int i = 1; i <= (M); i++) if (!s[i]) { puts("NO"); return 0; } puts("YES"); return 0; }
#include <bits/stdc++.h> using namespace std; int a[1005]; int main() { int n, m; cin >> n >> m; memset(a, 0, sizeof(a)); int x, w; for (int i = 0; i < n; i++) { cin >> x; for (int i = 0; i < x; i++) { cin >> w; a[w] = 1; } } for (int i = 1; i <= m; i++) { if (a[i] == 0) { cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 200; int vis[N]; bool f(int len) { for (int i = 1; i <= len; ++i) { if (!vis[i]) return false; } return true; } int main() { int i, j; int n, m; scanf("%d%d", &n, &m); for (i = 0; i < n; ++i) { int t; scanf("%d", &t); for (j = 0; j < t; ++j) { int tt; scanf("%d", &tt); vis[tt] = 1; } } cout << (f(m) ? "YES" : "NO") << endl; }
#include <bits/stdc++.h> using namespace std; template <class X> void input(vector<X>& a, int N) { X temp; for (unsigned long long int i = 0; i < N; i++) { cin >> temp; a.push_back(temp); } } template <class X> void output(vector<X>& a) { for (auto i = a.begin(); i != a.end(); i++) { cout << *i << " "; } } void solve() { set<int> alpha; int a, beta; int temp; cin >> a >> beta; for (unsigned long long int i = 0; i < a; i++) { vector<int> b; cin >> temp; input(b, temp); for (int p : b) { alpha.insert(p); } } for (int i = 1; i <= beta; i++) { if (find(alpha.begin(), alpha.end(), i) == alpha.end()) { cout << "NO"; return; } } cout << "YES"; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> int main() { int n, n2, m, i, j, k = 0, a[10000], count = 0; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) { scanf("%d", &n2); for (j = 0; j < n2; j++) { scanf("%d", &a[k]); k++; } } for (i = 1; i <= m; i++) { for (j = 0; j < k; j++) { if (a[j] == i) { count++; break; } } } if (count == m) printf("YES"); else printf("NO"); }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y, a[1000] = {}, cnt = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> y; if (!a[y]) { cnt++; a[y] = 1; } } } if (cnt == m) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int n, m, x, y; unordered_set<int> S; cin >> n >> m; for (register int i = 0; i < (int)n; i++) { cin >> x; for (register int i = 0; i < (int)x; i++) cin >> y, S.insert(y); } cout << (S.size() == m ? "YES" : "NO"); }
#include <bits/stdc++.h> using namespace std; long long a[105], x, y, m, n; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> y; for (int i = 1; i <= y; i++) { cin >> x; a[x] = 1; } } for (int i = 1; i <= m; i++) if (a[i] != 1) { cout << "NO"; return 0; } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; bool all_on(bool vis[105], int n, int m) { int i; for (i = 1; i <= m; i++) { if (!vis[i]) return 0; } return 1; } int main() { int n, m, x, y; bool vis[105]; cin >> n >> m; int i, j; for (i = 1; i <= m; i++) { vis[i] = 0; } for (i = 1; i <= n; i++) { cin >> x; for (j = 0; j < x; j++) { cin >> y; vis[y] = true; } } if (all_on(vis, n, m)) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, x, y; set<int> st; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; for (int j = 0; j < x; j++) { cin >> y; st.insert(y); } } cout << (st.size() == m ? "YES" : "NO"); }
#include <bits/stdc++.h> int n, m, s, v, ans; bool occ[111]; int main() { scanf("%d%d", &n, &m); ans = 0; for (int i = 0; i < n; i++) { scanf("%d", &s); for (int j = 0; j < s; j++) { scanf("%d", &v); if (!occ[v]) ans++; occ[v] = true; } } printf("%s\n", ans < m ? "NO" : "YES"); return 0; }