description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
public class cf {
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(Reader in) {
br = new BufferedReader(in);
}
public FastScanner() {
this(new InputStreamRead... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;
/**... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
inline int read() {
char c = getchar();
int x = 0;
bool sgn = false;
while (c < '0' || c > '9') {
if (c == '-') {
sgn = true;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c & 15);
c = getchar();
}
return sgn ? -x : x;
}
i... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
bool vis[2005], root[2005], dad[2005];
int n, m, h, id[2005];
vector<vector<int> > g(2005);
char a[1005][1005];
struct dsu {
int p[2005], r[2005];
dsu() {
for (int i = 0; i <= n + m; i++) {
p[i] = i;
r[i] = 0;
}
}
int find_(int node) {
return... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
const int N = 1002;
int n, m, p[N + N], g[N + N][N + N], d[N + N], q[N + N], l, r = -1, f[N + N];
char a[N][N];
int Find(int k) { return k == p[k] ? k : p[k] = Find(p[k]); }
int main() {
int u, v;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
for (u = 1; u <... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #!/usr/bin/env python2
"""
This file is part of https://github.com/cheran-senthil/PyRival
Copyright 2019 Cheran Senthilkumar <hello@cheran.io>
"""
from __future__ import division, print_function
import itertools
import os
import sys
from atexit import register
from io import BytesIO
class dict(dict):
"""dict() ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 7;
const int mod = 1e9 + 7;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
using namespace std;
int n, m, a[maxn], fa[maxn], du[maxn];
char mp[maxn][maxn];
vector<int> v[maxn];
int Find(int x) { return fa[x] == x ? x : fa[x]... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
long long int dsu[(20ll + (long long int)2000)];
long long int hei[(20ll + (long long int)2000)];
void init(long long int n) {
for (long long int i = 0; i <= n; i++) dsu[i] = i, hei[i] = 1;
}
long long int xfind(long long int i) {
if (dsu[i] == i) return i;
return xfi... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> edge[2002];
vector<int> gath[2002];
vector<int> gage[2002];
bool check[2002][2002];
bool vis[2002];
int ans[2002];
int in[2002];
int f[2002];
queue<int> q;
int find(int x) {
if (x == f[x]) return x;
return f[x] = find(f[x]);
}
void topsort() {
wh... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int Maxn = 1000 + 10;
int pre[Maxn * 2], Hash[Maxn * 2], in[Maxn * 2], u[Maxn * Maxn * 2];
vector<int> G[Maxn * 2];
char table[Maxn][Maxn];
int Find(int x) {
if (pre[x] != x) pre[x] = Find(pre[x]);
return pre[x];
}
void union_(int x, in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... |
import java.util.*;
import java.io.*;
public class Q3 {
static int mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
static ArrayList<ArrayList<Integer>> list;
static int[] rt;
static int[] size;
static void initialize(int n){
rt = new int[n + 1];
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
public class D {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Solver solver = new Solver();
solver.solve(in, out);
out.close();
}
private s... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
string s[2009];
int indegree[3 * 2009], ans[3 * 2009], timer[3 * 2009], ctrid[2009],
ctr = 0, comp_no[3 * 2009], res[3 * 2009], comp = 0;
vector<int> g[3 * 2009], rev[3 * 2009], scc[3 * 2009], main_g[3 * 2009];
bool reached[3 * 2009];
inline void rev_dfs(int pos) {
re... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
char s[1111][1111];
int lessthan[2222];
vector<int> morethan[2222];
int f[2222], in[2222];
int root(int u) { return u == f[u] ? u : f[u] = root(f[u]); }
void merge(int u, int v) { f[root(u)] = root(v); }
int main() {
int n, m;
scanf("%d %d", &n, &m);
int N = n + m;
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
if (a < b) a = b;
}
const long long MOD = 998244353;
const long long MAX = 50000;
const double pi = acos(-1);
co... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int ans[N], fa[N], n, m, head[N], cnt, col[N], tot, in[N], num;
char a[1005][1005];
int vis[N];
struct ii {
int to, next;
} e[N];
inline void add(int u, int v) {
e[++cnt].to = v;
e[cnt].next = head[u];
head[u] = cnt;
in[v]++;
}
inline int fi... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class MainS {
static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
static final int INf = 1_000_000_000;
static FastReader reader;
static PrintWriter writer;
public static void main(String[] args) {
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.lang.System.exit;
public class D {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(new BufferedInputStream(System.in, 1 << 20));
Buffe... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Collection;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.io.IOException;
import j... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;
import java.util.LinkedList;
import java.math.*;
import java.lang.*;
import java.util.PriorityQueue;
import static java.lang.Math.*;
@SuppressWarnings("unchecked")
public class Solution implements R... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e3 + 69, MOD = 1e9 + 7;
char arr[MAXN][MAXN];
long long n, m, mark[MAXN], par[MAXN], sz[MAXN], ans[MAXN];
vector<long long> topol, g[MAXN], rev[MAXN];
long long find(long long v) {
if (par[v] == 0) return v;
return par[v] = find(par[v]);
}
void m... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int N, M, n;
char a[2000][2000];
bool G[2000][2000];
int comp[2000], C = 0, smaller[2000], val[2000];
queue<int> todo;
void eq_DFS(int u) {
comp[u] = C;
for (int v = 0; v < n; v++)
if (a[u][v] == '=' && comp[v] == -1) eq_DFS(v);
}
int main() {
ios_base::sync_with_... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x * f;
}
const int N = 2000005;
int deg[N], bel[N], fa[N], dis[N], n, m;
ch... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
import java.io.*;
public class gourmet {
int N, M, nodeN, compN;
int[] compID, inEdges, dishScores;
boolean[][] adj, rawAdj, equalAdj;
gourmet(BufferedReader in, PrintWriter out) throws IOException {
StringTokenizer st = new StringTokenizer(in.readLine());
N = Integ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
int binpow(int b, int p, int mod) {
int ans = 1;
b %= mod;
for (; p; p >>= 1) {
if (p & 1) ans = ans * b % mod;
b = b * b % mod;
}
return ans;
}
void pre() {}
vector<string> ss;
int n, m;
vector<vector<in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int head[2222], num[2222], in[2222], ans[2222];
char M[1111][1111];
struct node {
int u, v, next;
} e[1111111];
int fa[2222];
int find(int u) { return u == fa[u] ? u : fa[u] = find(fa[u]); }
int tot, k;
int n, m;
void add(int u, int v) {
e[tot].v = v;
e[tot].next = he... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
class UnionFind {
public:
explicit UnionFind(int size) : m_size(size, 1), m_subgroups(size) {
m_parent.reserve(size);
for (int i = 0; i < size; ++i) m_parent.push_back(i);
}
int subgroups() const { return m_subgroups; }
int groupSize(int i) { return m_size[... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | class mergefind:
def __init__(self,n):
self.parent = list(range(n))
self.size = [1]*n
self.num_sets = n
def find(self,a):
to_update = []
while a != self.parent[a]:
to_update.append(a)
a = self.parent[a]
for b in to_update:
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using namespace std;
vector<vector<int> > g;
vector<vector<int> > g1;
vector<set<int> > gcol;
vector<int> col;
int nw = 0;
void dfs(int v) {
col[v] = nw;
for (auto t : g[v])
if (col[t] == -1) dfs(... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int cnt[1005][3];
bool comp(int i, int j) {
if (cnt[i][2] != cnt[j][2]) return cnt[i][2] < cnt[j][2];
if (cnt[i][1] != cnt[j][1])
return cnt[i][1] < cnt[j][1];
else
return cnt[i][0] < cnt[j][0];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOExcept... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
vector<int> par;
vector<int> sz;
vector<long long> w;
vector<vector<char> > a;
vector<vector<int> > lessy;
vector<vector<int> > more;
vector<int> color;
vector<bool> used;
vector<int> order;
bool globok = true;
int find_set(int v) {
if (par[v] == v)
return v;
else
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int T;
int n, m;
int num[4001], ans[4001];
char c[2001][2001];
struct Edge {
int to, next;
} edge[4000001];
int head[4001], sze;
int ru[4001], fa[4001];
bool vis[4001];
inline void add(int u, int v) {
edge[++sze] = (Edge){v, head[u]}, head[u] = sze;
}
inline int find(in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
inline int rd() {
int x = 0;
char c = getchar();
while (!isdigit(c)) c = getchar();
while (isdigit(c)) {
x = x * 10 + (c ^ 48);
c = getchar();
}
return x;
}
char a[2005][2005];
int n, m, f[2005], tot, hd[2005], deg[2005];
int find(int x) { return x == f[... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import sys
sys.setrecursionlimit(2000)
def dfs1(v, mintime):
localtime = mintime
vis1[v] = 1
for v2 in range(m):
if a[v][v2] == ">":
if not vis2[v2]:
dfs2(v2, 1)
localtime = max(localtime, time2[v2] + 1)
for v2 in range(m):
if a[v][v2] == "=":
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
public class D{
static class... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, mod = 998244353;
template <class o>
inline void qr(o &x) {
x = 0;
char c = getchar();
int f = 1;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + (c ^ 48);
c = ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
string str[N];
int pr[N];
int find(int r) {
if (pr[r] == r)
return r;
else
return pr[r] = find(pr[r]);
}
vector<pair<int, int> > edges;
set<int> g[N];
int vis[N];
void dfs(int node) {
vis[node] = 1;
for (int i : g[node]) {
if (vis[i] ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream &operator<<(ostream &out, pair<S, T> const &p) {
out << p.first << " " << p.second;
return out;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> const &v) {
long long int l = v.size();
for (long long int i... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int n, m;
char c;
vector<pair<int, int> > vec[maxn * 2];
int du[maxn * 2];
int dis[maxn * 2], vis[maxn * 2], cnt[maxn * 2];
const int INF = 0x3f3f3f3f;
bool spfa(int s) {
memset(dis, -1, sizeof(dis));
memset(vis, 0, sizeof(vis));
queue<int> que;... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
Gold = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
lo... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @description: 模拟搜索(dfs、dsu、dp、……)
* @Auther: wuxianhui
* @Create: 2019/3/6 09:06
*/
public class SimulationSearch {
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | def prov(mass, now):
check = True
for i in range(n):
for k in range(m):
if now[i][k] == '>' and mass[i] <= mass[n + k]:
check = False
break
elif now[i][k] == '<' and mass[i] >= mass[n + k]:
check = False
break
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
public class temp4 {
static ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
vector<int> v[3005];
int r[3005];
int f(int a) {
if (r[a] == a)
return a;
else
return r[a] = f(r[a]);
}
void u(int a, int b) {
a = f(a);
b = f(b);
if (a == b) return;
r[a] = b;
}
vector<int> o[3005], in[3005];
vector<int> top;
int st[3005];
bool ff;
void... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int mx = 2000 + 10;
int fa[mx], ma[mx][mx], co[mx], score[mx];
int n, m;
char str[mx];
vector<int> ve[mx];
queue<int> qu;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main() {
scanf("%d%d", &n, &m);
for (in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int M = 1e6 + 5;
int n, m;
char ch[N][N];
int fa[N], num[N], d[N], d2[N];
int Next[M], ver[M], tot, head[N], ans;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void add(int x, int y) {
ver[++tot] = y;
Next[tot] = head[x];
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int grid[1010][1010];
int id[2010];
int sz[2010];
int ans[2020];
vector<int> nodes[2020];
int vis[2020];
int deg[2020];
bool flag = false;
void dfs(int v) {
vis[v] = 1;
for (auto x : nodes[v]) {
if (vis[x] == 1) flag = true;
if (vis[x... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @autho... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
Finish_read = 0;
x = 0;
int f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
if (ch == EOF) return;
ch = getchar();
}
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= ch == '-', ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
const int N = 2005, M = N * N;
int fa[N];
void ufs_in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.StringTokenizer;
imp... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 4e6 + 10;
int head[maxn], in[maxn], dep[maxn], vis[maxn];
struct Edge {
int f, t, next;
Edge(int f = 0, int t = 0, int next = 0) : f(f), t(t), next(next) {}
} edge[maxn * 2];
string G[1005];
int cnt;
int fa[maxn], equ[maxn];
int findset(int e) { return ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
~debug() { cerr << endl; }
template <class c>... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 150010;
int a[2100];
int pre[2100];
int n, m;
char s[1100][1100];
vector<int> v[2100];
int in[2100];
int f(int x) { return x == pre[x] ? x : pre[x] = f(pre[x]); }
int main() {
int ans = 0;
scanf("%d%d", &n, &m);
for (int i = 1; i <= 2000; i++) pre[i] = i... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int n, m;
char sym[1000][1000 + 1];
vector<int> f;
int getF(int x) { return f[x] == x ? x : f[x] = getF(f[x]); }
void read_data() {
cin >> n >> m;
f.resize(n + m);
for (int i = 0; i < n + m; i++) f[i] = i;
for (int i = 0; i < n; i++) {
scanf(" %s", sym[i]);
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
struct edge {
int y, nxt, z;
} e[N * N];
int p[2 * N], deg[2 * N], ans[N * 2], fa[N * 2];
int eid, n, m;
char s[N][N];
int getf(int x) {
if (fa[x] == x)
return x;
else
return fa[x] = getf(fa[x]);
}
void merge(int x, int y) { fa[getf(x)] ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int nedge, head[2005];
struct Edge {
int to, nxt;
} edge[2000005];
int in[2005];
void add(int x, int y) {
edge[++nedge].nxt = head[x];
edge[nedge].to = y;
head[x] = nedge;
in[y]++;
}
int fa[2005], ans[2005];
int Find(int x) { return x == fa[x] ? x : fa[x] = Find(f... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
public class D {
static class DSU {
private final int n;
private final int[] root;
DSU(int n) {
this.n = n;
root = new int[n + 1];
for (int i = 0; i <= n; i++) {
root[i] = i;
}
}
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int inf = 1e9 + 4;
const int M = 3e3 + 5;
vector<int> vt[M];
char s[M][M];
int in[M];
int pre[M];
int ori[M], res[M];
int findroot(int r) {
if (r == pre[r]) return r;
return pre[r] = findroot(pre[r]);
}
int main() {
int n, m, l, r, len, cnt... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
char c[1010][1010];
vector<int> g[200001];
vector<int> larger[200001];
int component[200001];
int timer = 0;
void dfsinit(int v) {
component[v] = timer;
for (auto to : g[v]) {
if (!component[to]) dfsinit(to);
}
}
int used[200001];
int dp[200001];
int timer1 = 0;
v... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1111 * 2;
vector<int> G[maxn];
char mp[maxn][maxn];
int du[maxn], num[maxn];
int cnt = 1;
int fa[maxn];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void uni(int x, int y) {
x = find(x), y = find(y);
if (x != y) fa[y] = x;
}
int main... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
long long n, m, i, p[2020], b[2020], d[2020], ta, tb, taa, tbb, j;
char a[2020][2020];
vector<long long> v[2020];
long long car(long long aa) {
if (aa == p[aa])
return aa;
else
return p[aa] = car(p[aa]);
}
void dfs(long long aa) {
b[aa] = 1;
long long ii;
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | /*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
public class Main {
/*********************************************Constants******************************************/
static PrintWriter out=new PrintWriter(new OutputStreamWr... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int getint() {
int ans = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ans = ans * 10 + c - '0';
c = getchar();
}
return ans * f;
}
int f[10010];
int _(int x) { ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
import java.util.stream.*;
public class D {
public Object solve () {
int N = sc.nextInt(), M = sc.nextInt();
char [][] S = sc.nextChars(N);
int [][] A = new int [N][M];
for (int i : rep(N))
for (int j : rep(M))
A[i][j] = eval(S[i][j]);
int [][] Z = new int [N+M][];
for (int ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import sys
import random, math
from collections import defaultdict
def union(a,b):
global de
for el in de[b]:
ds[el] = a
de[a].add(el)
del(de[b])
n,m = [int(__) for __ in raw_input().split()]
arr = list()
arc = [[] for x in range(m)]
ds = dict()
de = defaultdict(set)
darr = defaultdict(... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 1;
char a[N][N];
int f[N * 2], head[1000001], vis[2 * N], d[N * 2], d1[N * 2], bj[N * 2];
int ask(int x) { return x == f[x] ? x : f[x] = ask(f[x]); }
struct node {
int next, to;
} e[N * N];
int tot;
void add(int x, int y) {
e[++tot].to = y;
e[tot]... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int n, m, par[5005];
vector<int> sz[5005];
string s[5005];
int f(int i) {
if (par[i] != i) par[i] = f(par[i]);
return par[i];
}
void merge(int a, int b) {
a = f(a), b = f(b);
if (a == b) return;
if (sz[a].size() < sz[b].size()) {
par[a] = b;
for (__typeof(... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int getint() {
int ans = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ans = ans * 10 + c - '0';
c = getchar();
}
return ans * f;
}
int f[10010];
int _(int x) { ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 1005;
char s[N][N];
int fa[2 * N], st[N * 2], ans[N * 2], deg[N * 2];
int n, m, in_path[N * 2];
vector<int> E[N * 2];
int find(int x) {
if (fa[x] == x) return x;
return fa[x] = find(fa[x]);
}
void dfs(int u, int& _c) {
if (!_c) return;
in_path[u] = 1;
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
int n, m, f[2005], fa[2005], g[2005];
vector<int> d[2005], d2[2005];
queue<int> q;
set<int> s;
int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
void Union(int x, int y) { fa[Find(x)] = Find(y); }
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = INT_MAX;
const long double pi = 4 * atan((long double)1);
vector<int> AdjList[2005];
int ran[2005];
int parent[2005], siz[2005], up[2005];
bool check;
int visited[2005];
bool les[2005], pass[2005];
void make_set(int v) {
parent[v] ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
import java.io.*;
import java.math.*;
import java.util.Comparator;
public class Main
{
static int[] p;
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stk = new StringTokenize... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
public class Main {
static ArrayList<Node> V = new ArrayList<>();
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
char[][] ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.ArrayList;
public class P1131D
{
private static int n, m;
private static int[][] a;
private static ArrayList<Dishes> dishes1, dishes2;
private static class Dishes
{
private ArrayList<Dishes> more, equal;
private boolean progressing, checked;
private int score;
priva... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import sys
from collections import deque
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
N, M = map(int, readline().split())
L = [readline().strip() for i in range(N)]
def root(x):
if x == p[x]:
return x
p[x] = y = root(p[x])
return y
def unite(x, y):
px = root(x); py = root(y)
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
inline void in(int &n) {
n = 0;
int ch = getchar();
int sign = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') sign = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
n = (n << 3) + (n << 1) + ch - '0', ch = getchar();
}
n = n * sign;
}
in... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | n, m = (int(t) for t in input().split(' '))
def direction(c):
if c == '=': return 0
if c == '>': return 1
return -1
mx = [[direction(c) for c in input()] for _ in range(n)]
index = 0
class DSet(object):
def __init__(self, value):
global index
self.values = set([value])
self.ind... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using namespace std;
vector<vector<int> > g;
vector<vector<int> > g1;
vector<set<int> > gcol;
vector<int> col;
int nw = 0;
void dfs(int v) {
col[v] = nw;
for (auto t : g[v])
if (col[t] == -1) dfs(... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
const int N = 1e3;
const int inf = 1e7;
using namespace std;
int n, m, fa[N * 2 + 5], id[N + 5][N + 5], idc, mp[N * 2 + 5][N * 2 + 5],
f[N * 2 + 5], d[N * 2 + 5], q[N * N + 5];
char ch[N + 5][N + 5];
int find(int x) {
if (fa[x] == x) return x;
return fa[x] = find(fa[x]);
}
void topo() {... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
public class MainClass
{
static int n, m;
static char[][] A;
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static StringBuilder stringBuilder = new StringBuilder();
static boolean[] visited;
static int[] ids;
static Li... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
char ara[1005][1005];
int par[2005], levv[2005], mini;
vector<int> ls[2005];
bool vis... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
public class ACM {
private static int find(int k, int[] fa) {
fa[k] = (fa[k] == k ? k : find(fa[k], fa));
return fa[k];
}
public static void main(String[] args) {
int N = 2010;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
i... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
try (PrintWriter out = new PrintWriter(System.out)) {
Solution solution = new Solution();
solution.in = new InputReader(getInput());
solu... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import sys
import collections
def main():
input = iter(sys.stdin)
N, M = map(int, next(input).split())
dsu = DSU(N + M)
edges = []
for i in range(N):
line = next(input).strip()
for j, sign in enumerate(line):
j = j + N
if sign == '=':
dsu.mer... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
import java.util.function.Function;
public class MainD {
static int N, M;
static char[][] C;
public static void main(String[] args) {
FastScanner sc = new FastScanner(System.in);
N = sc.nextInt();
M = sc.nextInt();
C = new char[N][];
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 20001;
int p[N], a[N];
int n, m, judge = 0;
int t[N], ans[N], b[N];
char s[1020][1020];
vector<int> v[2080];
int f(int x) {
if (p[x] == x) return x;
return p[x] = f(p[x]);
}
void unite(int x, int y) {
int xx = f(x), yy = f(y);
p[yy] = p[xx];
}
int main... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
vector<int> g[2007];
char s[1007][1007];
int fa[2007], vis[2007], shu[2007];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int flag = 0;
void dfs(int u) {
vis[u] = -1;
shu[u] = 1;
for (int i = 0; i < g[u].size(); i++) {
int v = g[u][i];
if (... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var n = nums[0], m = nums[1];
var s = Array(n).fill([]);
for (var i=0; i<n; i++) {
var q = readline();
s[i] = [];
for (var j=0; j<m; j++) s[i].push(q[j]);
}
var rank = Array(n+m).fill(0);
var ppp = Array(n+m).fill(0);
for (var i=0; i<n+m; i++... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
public class toy {
static int[] f=new int[2123];
public static int F(int x) {
return x==f[x]?x:(f[x]=F(f[x]));
}
public static void U(int a,int b) {
f[F(a)]=F(b);
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int m=in.nextInt();
... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > P;
vector<int> par, rang;
vector<bool> used;
vector<int> used1;
vector<int> Count;
int pred(int v) {
if (par[v] == v)
return v;
else
return par[v] = pred(par[v]);
}
void in(int a, int b) {
a = pred(a);
b = pred(b);
if (a != b && rang[a... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
int par[N];
int Find(int i) {
if (par[i] != i) par[i] = Find(par[i]);
return par[i];
}
int Union(int a, int b) {
a = Find(a), b = Find(b);
if (a == b) return 0;
par[b] = a;
return 1;
}
char G[N][N];
vector<int> adj[N];
int vis[N];
int hasC... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static class FastReader {
BufferedReader br;
StringTokenizer root;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (root == null || !root.hasMo... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main
{
static final long mod=(int)1e9+7;
static ArrayList<Integer>[] adj;
static int[] parent,size,arr,vis;
public static void main(String[] args) throws Exception
{
FastReader in=new FastReader();
PrintWriter pw=new PrintWriter(S... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | '''input
3 3
>>>
<<<
>>>
'''
#print(input().split())
n, m = list(map(int, input().split()))
#exit(0)
g = []
for i in range(n):
g += [input()]
# print(g)
memo = {}
def dfs(u):
if u not in memo:
memo[u] = res = 1
if u < n:
for v in range(m):
if g[u][v] == '>':
res = max(res, dfs(n + v) + 1)
for v ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
struct node {
int to, next;
} q[4012030];
char a[1020][1020];
int fa[2013], head[2013], ss, rd[2013], V[2013], que[2013];
bool vis[2013];
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline void Union(int x, int y) {
int a = find(x), b = find(... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int low[N], num[N], cnt;
vector<int> S;
int scc_cnt, scc[N];
int vis[N];
vector<int> g[N];
void tarjanSCC(int u) {
low[u] = num[u] = ++cnt;
vis[u] = 1;
S.push_back(u);
for (int v : g[u]) {
if (!num[v]) tarjanSCC(v);
if (vis[v]) low[u] = m... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int MX = 2e3 + 5;
vector<int> g[MX];
int in[MX];
int fa[MX];
char mp[MX][MX];
int ans[MX];
int found(int x) {
if (fa[x] == x) return x;
return fa[x] = found(fa[x]);
}
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n ... |
Mr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method of review — in each restaurant Mr. Apple orders two sets of dishes on two different days. All the di... | import java.io.*;
import java.util.*;
public class D {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Solver solver = new Solver();
solver.solve(in, out);
out.close();
}
private s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.