solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
inline int read(void) {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return f * x;
}
const int maxn = 50... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long po(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) {
res = (res * a) % 1000000007;
}
a = (a * a) % 1000000007;
b = b / 2;
}
return res % 1000000007;
}
long long n, s, f, ans, p, da, arr[100005], l, r;
int main() ... | 3 |
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const int maxn = 1e5 + 10;
const ll inf = 1e10;
int n, m;
ll a[maxn][2]; // color, val
bool viz[maxn];
vector<pair<ll,int... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, max = 0;
cin >> n;
int arr[1001] = {0};
for (i = 1; i <= n; i++) {
cin >> k;
arr[k]++;
if (k > max) max = k;
}
for (i = 1; i <= max - 2; i++) {
if ((arr[i] != 0) && (arr[i + 1] != 0) && (arr[i + 2] != 0)) {
cout <<... | 1 |
#include <bits/stdc++.h>
using namespace std;
map<string, string> p, l;
int main() {
ios::sync_with_stdio(false);
int q;
cin >> q;
string a, b;
while (q--) {
cin >> a >> b;
if (l.find(a) == l.end()) {
p[a] = b;
l[b] = a;
} else {
p[l[a]] = b;
l[b] = l[a];
p.erase(a);
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1 << 21], temp[1 << 21];
int mp[1 << 21];
long long ans[22][2];
int mask[22];
void solve(int L, int R) {
if (L == R) return;
int M = (L + R) / 2;
solve(L, M);
solve(M + 1, R);
int l = L, r = M + 1;
int now = mp[R - L + 1];
int i = L;
while (l <=... | 3 |
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
int H, W, X, Y;
cin >> H >> W >> X >> Y;
if (H*W%2 == 1 && (X+Y)%2 == 1) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
| 0 |
#include <bits/stdc++.h>
const int N = 200000 + 10;
inline std::pair<int, int> operator+(const std::pair<int, int> &lhs,
const std::pair<int, int> &rhs) {
return std::pair<int, int>(lhs.first + rhs.first,
std::max(lhs.second, rhs.second));
}
int n, k, ... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2111111;
long long go(long long n) {
while (n % 3 == 0) n /= 3;
return n / 3 + 1;
}
int main() {
long long n;
cin >> n;
cout << go(n) << endl;
return 0;
}
| 1 |
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <n... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
for (int i = 0; i < 10; i++) {
if (i == 4) {
cout << "normal";
return 0;
}
cout << i << endl;
string s;
getline(cin, s);
if (s == "great!" || s == "don`t think so" || s == "don`t touch me!" ||
s == "not bad" || s ==... | 2 |
#include <bits/stdc++.h>
int a[105];
int b[105];
int visit[1000055];
int abs(int a) {
if (a < 0) a = -a;
return a;
}
int main() {
int e, t, i, j, k, pp, sign, sum, n;
scanf("%d", &t);
for (e = 1; e <= t; e++) {
scanf("%d", &n);
for (i = 1; i <= n; i++) scanf("%d", &a[i]);
memset(visit, 0, sizeof(v... | 1 |
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
void DBG() { cerr << "]" << '\n'; }
template <class H, class... T>
void DBG(H h, T... t) {
cerr << h;
if (sizeof...(t)) cerr << ", ";
DBG(t...);
}
const int MOD = (int)1e9 + 7;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
auto so... | 5 |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int nodes,u,v,degrees[100005]={},root;
long long arr[100005],totaledge[100005]={};
vector <int> node[100005];
bool ans=true;
void dfs(int titik,int par)
{
for(int i=0;i<node[titik].size();i++)
if(node[tit... | 0 |
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
using pii = pair<long long, long long>;
template <typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using Prior = priority_queue<T>;
const long long INF = 1E18;
const long long mod = 1E9 + 7;... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout << fixed << setprecision(13);
double n, r, ans;
cin >> n >> r;
ans = r * sin(acos(-1.0) / n) * (1 / (1 - sin(acos(-1.0) / n)));
cout << setprecision(7);
cout << ans << "\n";
}
| 3 |
#include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 20 | 1;
inline char gc() {
static char ibuf[RLEN], *ib, *ob;
(ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
return (ib == ob) ? EOF : *ib++;
}
inline int read() {
char ch = gc();
int res = 0;
bool f = 1;
while (!isdigit(c... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long inf = 1LL << 62;
int n;
long long c, p[100010], s[100010];
long long dp[100010], tmp[100010];
int main() {
scanf("%d%lld", &n, &c);
for (int i = 1; i <= n; i++) scanf("%lld", &p[i]);
for (int i = 1; i <= n; i++) scanf("%lld", &s[i]);
for (int j = 0; j <= n... | 5 |
#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
int mod = (int)1e9 + 7;
const int logN = 18;
const int inf = 1e9 + 9;
const int N = 3003;
int n, m, x, y, z, t;
vector<int> v[2][N];
vector<pair<int, int> > go[2][N];
int dist[N][N];
pair<int, int> Q[N];
pair<int, pair<pair<int, int>, pair<i... | 2 |
#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
solve();
return 0;
}
void solve() {
long long int n, l, a[111];
cin >> n >> l;
for (long long int i = 0; i < n; ++i) cin >> a[i];
long long int best = 0;
for (long long int i = l; i <= 100; ++i) {
long long int ans = 0;
for (... | 3 |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
const int mod = 1e9 + 7;
int dcmp(long double x, long double y) {
return fabs(x - y) <= 1e-12 ? 0 : x < y ? -1 : 1;
}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int N = 1e3 + 10;
int main() {
int n, m;
cin >> n >> m;
if (n == 0 && m != 0) {
cout << "Impossible" << endl;
return 0;
}
cout << max(n, m) << ' ' << n + max(0, m - 1) << endl;
return 0;
}
| 1 |
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 100010;
int a[N], b[N];
int num[N];
int main()
{
int n, m;
scanf("%d %d", &n, &m);
int sum = 0;
for (int i = 1; i <= m; i++)
scanf("%d", &num[i]),
sum += (num[i] & 1)... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long a[202020];
long long f[202020];
int n, m;
namespace force {
void main() {
while (m--) {
int op;
scanf("%d", &op);
if (op == 1) {
int x, v;
scanf("%d %d", &x, &v);
a[x] = v;
} else if (op == 2) {
int l, r;
scanf("%d %... | 5 |
#include <bits/stdc++.h>
using namespace std;
void computeLPSArray(long long* pat, long long M, long long* lps);
int KMPSearch(long long* pat, long long* txt, long long n, long long m) {
long long M = m - 1;
long long N = n - 1;
long long ans = 0;
long long lps[M];
computeLPSArray(pat, M, lps);
long long i ... | 4 |
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | 4 |
#include <bits/stdc++.h>
using namespace std;
const int M = 2e6 + 7;
int read() {
int ans = 0, f = 1, c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
ans = ans * 10 + (c - '0');
c = getchar();
}
return ans * f;
}
long long tot... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 4000006;
using ll = long long;
ll f[N];
int main() {
ll n, m;
while (cin >> n >> m) {
for (int i = 1; i <= n; i++) f[i] = 0;
f[1] = 1;
ll sum = 0;
ll sum2 = 0;
for (int i = 2; i <= n; i++) {
(f[i] += sum) %= m;
(f[i] += sum2... | 4 |
#include <bits/stdc++.h>
using namespace std;
class AKorotkiePodstroki {
public:
void solve(std::istream& in, std::ostream& out) {
int t;
in >> t;
while (t-- > 0) {
string s;
in >> s;
string r;
for (int i = 0; i < s.size(); i += 2) r += s[i];
r += *s.rbegin();
out << r... | 1 |
#include <bits/stdc++.h>
using namespace std;
int solve(int* arr, int n) {
int cnt = 0, head = arr[n - 1];
for (int i = n - 2; i >= 0; --i) {
if (arr[i] > head)
++cnt;
else {
head = arr[i];
}
}
return cnt;
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
i... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 1e5 + 5;
const long long int mod = 1e9 + 7;
int a[MAX_N];
int b[MAX_N];
void love() {
int n;
cin >> n;
int flag = -1;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> b[i];
if (flag != b[i]... | 2 |
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <str... | 0 |
#include <bits/stdc++.h>
using namespace std;
int func(int b,char s){
if(b==1) return s-'0';
return -(s-'0');
}
int main(){
string S;
cin>>S;
for(int i=0;i<(1<<3);i++){
bitset<3> b(i); //1を+
if(7-(S[0]-'0')==func(b[2],S[1])+func(b[1],S[2])+func(b[0],S[3])){
cout<<S[0];
... | 0 |
#include <bits/stdc++.h>
using namespace std;
int a[3001];
int main() {
int n, v;
cin >> n >> v;
long int s = 0;
for (int i = 0; i < n; ++i) {
int f, b;
cin >> f >> b;
a[f] = a[f] + b;
}
for (int i = 1; i < 3005; ++i) {
s = s + min(a[i], v);
a[i] = a[i] - min(a[i], v);
a[i + 1] = a[i... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MAX = 200005;
long long T[MAX * 8];
long long lazy[MAX * 8];
vector<pair<int, int> > input(int n) {
vector<pair<int, int> > v(n), nv;
for (auto &first : v) cin >> first.first ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int _;
cin >> _;
while (_--) {
long long int i, n;
cin >> n;
long long int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
if (a[0] < a[n - 1]) {
cout << ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int N;
char grid[128][128];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0), cout.precision(15);
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cin >> grid[i][j];
}
}
vector<int> cols;
for (int i = 0;... | 1 |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
int solve(vector<int>& a, int bit) {
if (bit < 0) {
return 0;
}
vector<int> b0, b1;
for (int& i : a) {
if (((1 << bit) & i) == 0) {
b0.push_back(i);
} else {
b1.push_back(i);
}
}
if (!b0.size()) {
return solv... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, i, j;
cin >> n;
vector<long long int> v[n];
long long int a, b, count = 0, temp1, temp2;
for (i = 0; i < n; i++) {
cin >> a >> b;
if (a != b) count++;
}
if (count > 0) {
cout << "Happy Alex";
} else {
cout << "Po... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int Maxn = 50 + 10;
int n, k, cnt;
long long f[Maxn][Maxn][2], c[Maxn][Maxn], sum, ans;
void assign() {
freopen("Ksenia and Combinatorics.in", "r", stdin);
freopen("Ksenia and Combinatorics.out", "w", stdout);
}
void close() {
f... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long bit[123456] = {0}, a[123456];
long long update(long long pos, long long val) {
while (pos < 112345) {
bit[pos] += val;
pos += pos & (-pos);
}
return 0;
}
long long query(long long pos) {
long long sumi = 0;
while (pos > 0) {
sumi += bit[pos];... | 5 |
#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 {
template <class c>
debug& operator<<(const c&... | 5 |
#include <stdio.h>
int main(void) {
int ans = 0, i;
char s[20], t[20] = "CODEFESTIVAL2016";
scanf("%s", s);
for(i = 0; i < 16; ++i) if(s[i] != t[i]) ++ans;
printf("%d\n", ans);
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
long long int getN(long long int sum) {
sum = sum * 8;
sum = sqrt(sum + 1) - 1;
sum /= 2;
return sum;
}
long long int apSum(long long int n) {
long long int a = 1, d = 1;
long long int res = (2 * a + (n - 1) * d) * n;
res /= 2;
return res;
}
long long int gc... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int numbers;
bool alien = false, elephant = false;
map<int, int> length;
for (int i = 0; i < 6; i++) {
cin >> numbers;
length[numbers]++;
}
for (std::map<int, int>::iterator it = length.begin(); it != length.end();
++it) {
if (it-... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--) {
int n, k, d;
cin >> n >> k >> d;
int trueAns = 0;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
if (d == 1) {
cout << 1 <<... | 2 |
#include<bits/stdc++.h>
using namespace std;
bool solve(){
int A,B,C,N,t[1000][3],r[1000];
cin>>A>>B>>C;
if(A==0&&B==0&&C==0)return false;
cin>>N;
for(int i=0;i<N;i++){
for(int j=0;j<3;j++){
cin>>t[i][j];
t[i][j]--;
}
cin>>r[i];
}
int S[1000]=... | 0 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b;
cin >> a >> b;
if (a < b) {
cout << 0 << endl;
} else if (a == b) {
cout << "infinity" << endl;
} else {
set<long long> sol;
for (long long i = 1; i * i <= (a - b); i++) {
if ((a - b) % i == 0) {
if (i >... | 2 |
#include <bits/stdc++.h>
using namespace std;
long long int arr[100005], dp[100005];
int main() {
long long int n, k;
cin >> n >> k;
for (long long int i = 1; i < n + 1; i++) cin >> arr[i];
dp[0] = 0;
for (long long int i = 1; i < n + 1; i++) {
if (arr[i] == 0) {
long long int val = (max(1LL, i - k)... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int a[10][10];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
int x1 = a[0][1] + a[0][2];
int x2 = a[1][0] + a[1][2];
int x3 = a[2][0] + a[2][1];
int y = ... | 2 |
#include<iostream>
using namespace std;
int main()
{
int n,i,x,minn=0x7fffffff,cnt=0;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>x;
if(x<=minn)
{
minn=x;
cnt++;
}
}
cout<<cnt<<endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
long long int M = 1000000007;
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << setprecision(25);
;
long long int T = 1;
while (T--) {
long long int n, a, b, ans = 1e18, i;
cin >> n >> a >> b;
long long int arr[6];
for (i =... | 2 |
#include <bits/stdc++.h>
const int N = 50;
int n, dp[N + 2][N + 2][N + 2][N + 2];
char str[N + 3];
int dfs(int x, int y, int z, int w) {
if (~dp[x][y][z][w]) return dp[x][y][z][w];
dp[x][y][z][w] = std::max(z - x + 1, w - y + 1);
for (int i = x; i < z; ++i)
dp[x][y][z][w] =
std::min(dp[x][y][z][w], df... | 4 |
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#d... | 1 |
#include <bits/stdc++.h>
using namespace std;
long long int n, x, pos, sm, bg, s, e, mid, ncr[1010][1010], fact[1010];
int main() {
for (int i = 0; i < 1010; i++) {
for (int j = 0; j <= i; j++) {
if (j == 0 || i == j)
ncr[i][j] = 1;
else
ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) ... | 3 |
#include <bits/stdc++.h>
using namespace std;
char s[500];
int get(char c) {
int q = int(c);
return q;
}
int mirror(int code) {
int res = 0;
for (int i = 0; i < 8; i++) {
if ((code & (1 << i)) != 0) {
res |= (1 << (7 - i));
}
}
return res;
}
int main() {
gets(s);
int n = strlen(s);
for (... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int maxlongint = 2147483647;
const int biglongint = 2139062143;
struct ljb {
int dest, flow, cost;
ljb *next, *other;
} * head[7005], *tail[7005], *p, *pre[7005];
int m, n, uu, rc, fc, ans1, ans2, S, o, v;
int a[105][105], biao[105][105], flag[10005], cost[10005],... | 3 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
long long t[1502][1502];
long long dp[1502][1502];
long long pf[1502][1502];
int main() {
cin >> n >> m;
for (int i = 0; i < n + 1; i++) {
for (int j = 0; j < m + 1; j++) {
if (i < n && j < m) scanf("%lld", &t[i][j]);
dp[i][j] = -(1LL << 62);
... | 5 |
#include <bits/stdc++.h>
long long x;
int a[100100], b[100100], c[100100], dd[100100], bb[100100], c1[100100],
c2[100100], kk[100100], n, d, i, z, xx, j, t1, t2, k, bk, ck;
int getNextX() {
x = (x * 37 + 10007) % 1000000007;
return (int)x;
}
void initAB() {
for (i = 0; i < n; i++) a[i] = i + 1;
for (i = 0; ... | 2 |
#include <bits/stdc++.h>
int a[105], stor[105];
int main() {
int n;
scanf("%d", &n);
int i;
for (i = 0; i < n; i++) scanf("%d", &a[i]);
int j, k = 0, max;
max = a[2] - a[0];
for (i = 1; i < n - 1; i++) {
if (i == 1) {
max = a[2] - a[0];
for (j = 2; j < n - 1; j++) {
if (a[j + 1] - ... | 1 |
#include <bits/stdc++.h>
using namespace std;
void Go() {
long long int L, R;
cin >> L >> R;
if (2 * L <= R)
cout << L << " " << 2 * L << '\n';
else
cout << "-1 -1\n";
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t = 1;
cin >> t;
while (t--) {
Go();
}... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string a, b;
cin >> a;
int len, res;
b = a;
len = a.length();
a += a;
a.erase(0, 1);
res = a.find(b);
cout << res + 1;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
long long segt[((long long)1 << 19) + 5];
long long constr(long long l, long long r, long long mas[], long long pos) {
if (l == r) {
segt[pos] = mas[l];
return 1;
} else {
long long mid = (l + r) / 2;
long long bij = constr(l, mid, mas, pos * 2 + 1);
... | 4 |
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct node{
int x,y;
node(int a,int b):x(a),y(b){}
};
int vis[maxn],f[maxn],l[maxn];
int main(){
int n,k;
scanf("%d%d",&n,&k);
scanf("%d",&f[1]);
for(int i=2;i<=n;++i){
int x;
scanf("%d",&x);
f[i]=x;
vis[x]++;
}
int ans=0;
if(f[1]!=1)... | 0 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int sx,sy,tx,ty;
cin>>sx>>sy>>tx>>ty;
cout<<string(tx-sx,'R')+string(ty-sy,'U')+string(tx-sx,'L')+string(ty-sy+1,'D')+string(tx-sx+1,'R')+string(ty-sy+1,'U')+'L'+'U'+string(tx-sx+1,'L')+string(ty-sy+1,'D')+'R'<<endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a, distinct;
int x, n;
int space;
cin >> n >> space;
for (int i = 0; i < n; ++i) {
cin >> x;
a.push_back(x);
}
distinct.resize(n);
space *= 8;
int reqd = space / n;
if (reqd > 30 or n <= (1 << reqd)) {
cout << 0 << '\... | 1 |
#include <bits/stdc++.h>
using namespace std;
char aaa[33][33] = {
1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0,
1, 1, 0, 1, ... | 2 |
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#defi... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000000;
int n1, n2, xx, yy, m, r, b, Lid[810], Rid[810], idt, S, T, SS, TT, et, be[810],
lows, erid[331000], ebid[331000], ansc, answ;
char s[810], ans[810];
struct edg {
int v, c, w, ne;
} e[331000];
inline void adde(int u, int v, int c, int w) {
... | 6 |
#include <bits/stdc++.h>
const double pi = 3.1415926535897932384626433832795;
bool test(long long x1, long long y1, long long x2, long long y2, long long x3,
long long y3) {
long long vx1 = x2 - x1;
long long vy1 = y2 - y1;
long long vx2 = x3 - x1;
long long vy2 = y3 - y1;
return ((vx1 * vx2 + vy1 *... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long n, p;
bool ok(long long a, int b) {
if (a < 0) return 0;
if (b > a) return 0;
while (a) {
if (a % 2) b--;
a /= 2;
}
return b >= 0;
}
int main() {
scanf("%lld%lld", &n, &p);
for (int i = 0; i < 100; i++, n -= p)
if (ok(n, i)) {
print... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e6 + 10;
const long long inf = 1e15;
long long mod = 1e9 + 7, fac[MAX], a[MAX], b[MAX];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, m;
long long ans = 0;
long long x = 0, y = 0;
cin >> n >> m;
for (long lon... | 2 |
#include <bits/stdc++.h>
using namespace std;
string str[10];
int main() {
str[0] = "O-|-OOOO";
str[1] = "O-|O-OOO";
str[2] = "O-|OO-OO";
str[3] = "O-|OOO-O";
str[4] = "O-|OOOO-";
str[5] = "-O|-OOOO";
str[6] = "-O|O-OOO";
str[7] = "-O|OO-OO";
str[8] = "-O|OOO-O";
str[9] = "-O|OOOO-";
string input;... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
if (n % 2 == 0) {
string a;
string x[2];
x[0] = "aa";
x[1] = "bb";
for (int i = 0; 2 * i < n; i++) a += x[i % 2];
string b = a.substr(2);
for (int i = 0; i < b.size(); ++i) b[i] += 2;
string c = b;
for ... | 1 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b >> c;
int k,cnt=0;
cin >> k;
while(a>=b){
b*=2;
cnt++;
}
while(b>=c){
c*=2;
cnt++;
}
if(cnt>k) cout << "No\n";
else cout << "Yes\n";
} | 0 |
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
if (a < b) a = b;
}
int power(int a, int b, int m, int ans = 1) {
for (; b; b >>= 1, a = 1LL * a * a % m)
if (b & 1)... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
while (~scanf("%d%d", &x, &y)) {
double z = sqrt(x * x * 1.0 + y * y * 1.0);
int k = (int)z;
if (x > 0 && y > 0 || x < 0 && y < 0) {
if (z == k)
printf("black\n");
else {
if (k & 1)
printf("white\n... | 1 |
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
using namespace std;
int n;
int in[5100];
unordered_set<int> vs;
int Solve(int x, int y) {
int d = y - x;
if (vs.count(x-d) > 0) return 0;
int r = 1;
for (int x = y; vs.count(x) > 0; x += d) {
r++;
}
return r;
}
int ... | 0 |
#include <bits/stdc++.h>
using namespace std;
#define N 200050
int a[N];
int main(){
int n, k;
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
for(int i = k; i < n; i ++){
if(a[i] > a[i - k]) puts("Yes");
else puts("No");
}
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int ts, kk = 1, _DB = 1;
inline int LEN(string a) { return a.length(); }
inline int LEN(char a[]) { return strlen(a); }
template <class T>
inline T _abs(T n) {
return (n < 0 ? -n : n);
}
template <class T>
inline T _max(T a, T b) {
return (a > b ? a : b);
}
template <cl... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> cnt(256, 0);
string s;
cin >> s;
for (auto c : s) cnt[c]++;
vector<int> odds;
for (char i = 'a'; i <= 'z'; ++i)
if (cnt[i] % 2 == 1) odds.push_back(i);
int K = odds.size();
for (int i = 0; i < K / 2; ++i) cnt[odds[i]]++, cnt[odds... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 7;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
const int N = 4e5 + 1;
int n, m, p;
pair<int, int> a[N], b[N];
struct Data {
int x, y, z;
Data(int x, int y, int z) : x(x), y(y), z(z) {}
};
vector<Data> ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
(ios_base::sync_with_stdio(false), cin.tie(nullptr));
int t;
t = 1;
while (t--) {
int n, m;
string s;
cin >> n >> m >> ws;
map<string, int> mp;
for (int i = 0; i < n; i++) {
getline(cin, s);
mp[s]++;
}
int common ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long ans = 0;
for (long long p2 = 1; p2 <= n; p2 *= 2) {
ans += n / p2;
if (p2 > LLONG_MAX / 2) break;
}
... | 3 |
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
#include <assert.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
string parse_target;
string::const_ite... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, t, ci, ti, r=1001;
cin>>n>>t;
while(n--){
cin>>ci>>ti;
if(ti<=t && ci<r){
r=ci;
}
}
r<1001?cout<<r:cout<<"TLE";
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
const int maxint = 2147483647;
const int minint = -2147483647;
const unsigned int maxunint = 4294967295;
const int N = 200000;
int h[5005];
int f(int l, int r, int p) {
int i, minh = h[l], m = l;
for (i = l; i <= r; i++) {
if (h[i] < minh) {
minh = h[i];
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int n;
long long ans = 0;
long long a[500005];
int c[500005];
long long bit[500005];
vector<long long> b;
void add(int k, long long x) {
while (k <= n) {
bit[k] = (bit[k] + x) % 1000000007;
k += k & (-k);
}
}
long long query(int k) {
long long sum = 0;
while... | 6 |
#include <bits/stdc++.h>
size_t gcd(size_t a, size_t b) {
while (a && b) {
size_t rem = a % b;
a = b;
b = rem;
}
return a + b;
}
long solve(std::vector<size_t> const &len, std::vector<size_t> const &cst) {
std::map<size_t, size_t> dt;
for (size_t i = 0; i != len.size(); ++i)
if (dt.find(len[i]... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;cin>>N;
int P[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int L[15];int n;
for(int i=0;i<15;i++){
n=N;L[i]=0;
while(n>0){
n=n/P[i];
L[i]+=n;
}
}int id[]={74,24,14,4,2};
int j=0,tem... | 0 |
#include<iostream>
using namespace std;
int main(){
string s;
cin >> s;
int x=0;
if(s[0]=='R')
x++;
if(s[1]=='R')
x++;
else{
x=0;
}
if(s[2]=='R')
x++;
if(s[0]=='R' && x==0)
x++;
cout << x << endl;
return 0;
} | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
vector<vector<int>> b(4, vector<int>(4));
string s;
cin >> s;
int n = s.length(), i, j, k, l;
for (i = 0; i < n; i++) {
if (s[i] == '0') {
for (k = 0; k < 4; k++) {
for... | 1 |
#include <bits/stdc++.h>
using namespace std;
char s[100010];
char word[100010];
int num[100010];
int change() {
int len = strlen(word);
if (len < 3) return 0;
if (strcmp(word + len - 4, "lios") == 0) return 1;
if (strcmp(word + len - 5, "liala") == 0) return -1;
if (strcmp(word + len - 3, "etr") == 0) return... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, p = 0, c = 0, l;
long long int i, n, k;
cin >> n >> t;
long long int a[200001];
for (i = 0; i < n; i++) {
cin >> a[i];
p += a[i];
if (i == 0)
k = a[i];
else
k = min(k, a[i]);
}
c = t / p * n;
t = t % ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int n, x, a[3];
int main() {
scanf("%d%d", &n, &x);
n = n % 6;
switch (n) {
case 0:
a[0] = 0;
a[1] = 1;
a[2] = 2;
break;
case 1:
a[0] = 1;
a[1] = 0;
a[2] = 2;
break;
case 2:
a[0] = 1;
a[1] = 2;
... | 1 |
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
class UnionFind {
std::vector<int> p;
public:
UnionFind(int n) : p(n, -1) {}
int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
bool same(int x, int y) { return... | 0 |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
uniform_int_distribution<long long> uid(l, r);
return uid(rng);
}
const int N = 5e5 + 5;
bool vis[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);... | 6 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#... | 0 |
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long int64;
const int64 MOD = (int64)( 1e9 + 7 );
const int MAX_N = int(1e5);
const int MAX_K = int(1e3);
struct WarpHole {
int sy, sx, gy, gx;
WarpHole(){}
WarpHole(int sy, int sx, int gy, int gx):
sy(sy), sx(sx), gy(g... | 0 |
#include<algorithm>
#include<cstdio>
int main(){
int sen[10000];
int bit[1024];
int num[1024],s;
for(int i=0;i<1024;i++)
for(num[i]=0,s=i;s>0;s >>= 1)num[i]+=s&1;
int r,c,cc;
while(true){
scanf("%d %d",&r,&c);
if (!r)break;
for(int i=0;i<c;i++) sen[i] = 0;
for(int j=0;j<r;j++){
for(int i=0;i<c;i+... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.