solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 107;
const int MAXT = 2007;
const int MAXE = 207;
const int INF = 0x3f3f3f3f;
int n;
struct Item {
int t, d, p, nu;
Item() {}
Item(int t, int d, int p) : t(t), d(d), p(p) {}
bool operator<(Item i) const { return d < i.d; }
} item[MAXN];
struct Dp {
... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long t, n, m;
long long cust[105][3];
void solve() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> cust[i][j];
}
}
long long mn = m, mx = m, cur = 0;
for (int c = 0; c < n; c++) {
long long t = cust[c][0], l = cust[c][1], ... | 3 |
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, x, y;
long long HP, A, B, C, D, AA, BB, CC, DD;
inline long long dis(int x, int y, int xx, int yy) {
return abs(x - xx) + abs(y - yy);
}
inline void upd() {
A += dis(x, y, a, b);
B += dis(x, y, a, b + c - 1);
C += dis(x, y, a + c - 1, b);
D += dis(... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
unsigned long long a, b, c, d;
cin >> a >> b >> c >> d;
if (b >= a)
cout << b << endl;
else if (c <= d)
cout << "-1" << endl;
else {
unsigned long long tbed = b;
unsigned long long... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
;
long long n;
cin >> n;
long long d1 = n % 10;
long long d2 = n % 100 / 10;
long long x = n / 10;
long long y = n / 100 * 10 + d1;
cout << max({x, y, n});
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long bINF = 1e16;
const double EPS = 1e-9;
const double PI = acos(-1);
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int q;
scanf("%d", &q);
while (q--) {
int n;
scanf("%d", &n);
vecto... | 1 |
#include <bits/stdc++.h>
using namespace std;
vector<long long> dp;
void pre() {
for (long long i = 0; i < 63; i++) {
dp.push_back(pow(2, i));
}
}
void solution() {
long long n;
cin >> n;
long long ans = INT_MAX;
string s = to_string(n);
for (auto x : dp) {
long long k = 0;
string p = to_strin... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long a = 1;
long long n, k, ans;
long long v[100010];
vector<long long> V;
map<long long, int> M;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> v[i], v[i] += v[i - 1];
V.push_back(1);
if (k != 1 && k != -1)
while (a < 1e15) a *= k, V.push_... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
vector<int> a;
cin >> n;
int flag = 0;
int sum = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
if (t < 0) flag++;
if (flag == 3) {
a.push_back(sum);
flag = 1;
sum = 0;
}
sum++;
if (i == n - 1)... | 1 |
#include <bits/stdc++.h>
using namespace ::std;
const unsigned long long maxn = 310;
const unsigned long long inf = 1e9 + 500;
const unsigned long long mod = 1e9 + 7;
const unsigned long long maxm = 2e4 + 500;
unsigned long long a[maxn];
unsigned long long id[maxn];
vector<unsigned long long> ger[maxn];
bool npr[maxm];... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
struct tree {
vector<int> t;
tree() {}
tree(int n) : t(4 * n, 0) {}
void modify(int v, int l, int r, int pos, int val) {
if (l == r) {
t[v] = val;
return;
}
if (pos <= (l + r) / 2) {
modify(v * 2, l, (l + r) / ... | 5 |
#include <bits/stdc++.h>
using namespace std;
struct truck {
int a, b, c, d;
};
struct para {
int s, pop;
};
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
vector<truck> t(n);
for (int i = 0; i < n; ++i) cin >> t[i].a >> t[i].b >> t[i].c >> t[i].d;
map<pair<int, int>, set<pair<int, int> > >... | 4 |
#include <bits/stdc++.h>
const int MAXN = 200086;
char s[MAXN];
int mx[MAXN], c[MAXN], v[MAXN];
inline bool isv(const char x) {
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') return true;
if (x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U') return true;
return false;
}
int main() {
int i... | 5 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void bober() {
int n;
cin >> n;
vector<int> r(n + 1, n + 1), ans(n + 1, 0), cnt(n + 1, 0);
r[1] = 0;
for (int i = 2; i <= n; i++) {
if (r[i] < n + 1) {
cnt[r[i]]++;
continue;
}
r[i] = i;
cnt[i]++;
for (int j = ... | 3 |
#include <bits/stdc++.h>
using namespace std;
char in[1000], in1[1000];
vector<string> vs;
string s;
vector<string> shift(vector<string> vs) {
int i;
for (i = vs.size() - 1; i >= 1; i--) {
vs[i] = vs[i - 1];
}
vs[0] = "0000";
return vs;
}
int main() {
int T, n, i;
scanf("%d", &T);
gets(in);
while ... | 2 |
#include <bits/stdc++.h>
using namespace std;
vector<int> visited, active;
void dfs_visit(int root, const vector<vector<pair<int, int> > >& adj,
vector<int>& colors, int parent) {
visited[root] = 1;
active[root] = 1;
for (auto v : adj[root]) {
colors[v.second] = active[v.first] ? 2 : 1;
if ... | 4 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i = 0;i < n;i++)cin >> a[i];
sort(a,a+n,greater<int>());
cout << a[0]-a[n-1] << endl;
} | 0 |
#include <iostream>
using namespace std;
int n;
int p[100];
int cnt[101];
int main() {
int i;
cin >> n;
for (i = 0; i < n; i++) { cin >> p[i]; cnt[p[i]]++; }
for (i = 99; i >= 0; i--) cnt[i] += cnt[i + 1];
for (i = 100; i >= 0; i--) if (cnt[i] >= i) break;
cout << i << endl;
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n, a, b, y;
cin >> n;
cin >> a;
cin >> b;
long long int money;
if (b - 2 * a >= 0) {
cout << n * a << endl;
} else {
y = (a * n) / (2 * a - b);
if (y < (n / 2))
... | 1 |
#include <bits/stdc++.h>
using namespace std;
int X1, Y1, X2, Y2;
int a, b;
int main() {
long long int n, k, kk;
cin >> n >> k;
kk = k;
vector<long long int> v(n + 1, 0);
vector<long long int> b;
v[0] = 1;
v[1] = 1;
for (long long int i = 2; i <= n; i++) {
if (v[i] == 0) {
b.push_back(i);
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 3e18;
const int maxN = 1e5 + 100;
const int maxA = 1e6 + 1;
int main() {
int n;
cin >> n;
string s;
cin >> s;
string curr = "ogo";
while (curr.size() < s.size()) {
curr += "go";
}
while (curr.size() >= 3) {
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long maxn = 1000005;
double arr[maxn];
void solve() {
long long n, x;
cin >> n >> x;
priority_queue<double> pq;
for (long long i = (long long)(0); i < (long long)(n); i++) {
cin >> arr[i];
... | 2 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
for (const A &it : a) ... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
pair<int, int> p[N];
int n;
vector<pair<int, int> > cur, nxt;
int main() {
int m;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
int x, y;
scanf("%d%d", &x, &y);
p[i] = make_pair(x, y);
}
sort(p, p + m);
if (p[0].first == ... | 2 |
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
int n;
while(cin>>n){
if(n==0)break;
int team[n][n-1];
char name[n];
rep(i,n){
cin>>name[i];
rep(j,n-1){
cin>>team[i][j];
}
}
int win[n];
int lose[n];
rep(i,n){
wi... | 0 |
#include <bits/stdc++.h>
using namespace std;
int score[56];
int flag[56][56];
int main() {
int n;
cin >> n;
for (int i = 0; i < n * (n - 1) / 2 - 1; i++) {
int x, y;
cin >> x >> y;
score[x]++;
score[y]--;
flag[x][y] = 1;
flag[y][x] = 1;
}
for (int i = 1; i <= n; i++) {
for (int j ... | 2 |
//40
#include<iostream>
#include<utility>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main(){
queue<pair<vector<int>,int> > que;
static const int g[]={0,1,2,3,4,5,6,7};
vector<int> ov(g,g+8);
que.push(make_pair(ov,0));
map<vector<int>,int> m;
while(!que.empt... | 0 |
#include <bits/stdc++.h>
using namespace std;
pair<int, int> pii[10];
double ans = 0.0;
double cal(int n, int p, int vote, int A, int B) {
if (n == p) {
if (vote > n / 2)
return 1.0;
else
return 1.0 * A / (A + B);
}
double T = (1.0 * pii[p].second / 100);
double sum = T * cal(n, p + 1, vote ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a, b;
bool mark[200];
for (int i = 0; i < 150; i++) mark[i] = 0;
int n, a1, b1;
cin >> n >> a1 >> b1;
while (a1--) {
cin >> a;
mark[a] = true;
}
while (b1--) cin >> b;
... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e6;
int sum[2000010], s1[2000010], s2[2000010], c[2000010], p[2000010];
int ans, n, m;
inline int mo(int x) {
if (x >= MOD) return x - MOD;
return x;
}
void init() {
for (int i = 1; i <= N; i++) {
p[i] += i;
for (int j = i + i; j ... | 5 |
#include <bits/stdc++.h>
using namespace std;
long long dist(pair<long long, long long>& o, pair<long long, long long>& u) {
return abs(o.first - u.first) + abs(o.second - u.second);
}
int32_t main() {
long long a, b;
cin >> a >> b;
pair<long long, long long> tar = {a, b};
string s;
cin >> s;
pair<long lo... | 1 |
#include <iostream>
#include <math.h>
using namespace std;
void solve()
{
double n;
while(cin >> n, n)
{
int ans = 0;
int k = sqrt(n);
for(int a = 1; a <= k; ++a)
{
if(a * a > n)
{
break;
}
if(a * a == n)
{
++ans;
}
for(int b = a; b <= k; ++b)
{
if(a * a + b * b > n)
... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long a[100005];
long long dp[100005][2];
int main() {
long long res, n, k;
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n - 1; i++) {
a[i] = abs(a[i] - a[i + 1]);
}
long long ans = 0;
for (i... | 1 |
#include <bits/stdc++.h>
using namespace std;
long n, input[1200000];
vector<long> v;
map<long, long> mapp;
long calc;
long long span, tinv[200], linv[200];
long long p;
vector<pair<long, long> > ad;
long tests;
long lvl;
long long answ;
long vars[1200000];
class Fenwick {
long *m, *mt, N;
public:
Fenwick(long n)... | 3 |
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long mod = 1000000007;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
vector<long long> v;
long long a[105];
int main() {
long long n, k;
scanf("%I64d%I64d", &n, &k);
for (int i = 1; i <= n; i++) {
scan... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n;
int prime[maxn];
int cnt = 0;
bool flag[maxn * 2];
int ans[maxn];
void p() {
for (int i = 2; i <= n * 2; i++) {
if (!flag[i]) prime[cnt++] = i;
for (int j = 0; j < cnt; j++) {
if (i * prime[j] > maxn * 2) break;
flag[i ... | 1 |
#include <bits/stdc++.h>
using namespace std;
struct team {
string nam;
int pnts, sc, mis;
};
int n;
struct team t[50];
void add(const string &s, int a, int b) {
for (int i = 0; i < n; ++i)
if (t[i].nam == s) {
if (a > b)
t[i].pnts += 3;
else if (a == b)
t[i].pnts += 1;
t[i].... | 1 |
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_N 100005
int par[MAX_N];
int ran[MAX_N];
void init(int n){
for(int i = 0; i < n; i++){
par[i] = i;
ran[i] = 0;
}
}
int find(int x){
if(par[x] == x)return x;
else return par[x] = find(par[x]);
}
void unite(int x... | 0 |
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, s, y, x, z;
cin >> n >> s >> y >> x >> z;
int q = 0, f = 0, ans = 1;
if (y == n)q++;
if (z == n)q++;
if (y == n - 1)f++;
if (z == n - 1)f++;
if (s < q || x < q)ans = 0;
if (s + x < f+2... | 2 |
#include <bits/stdc++.h>
using namespace std;
int l;
char s[110000];
int main() {
while (~scanf("%s", s)) {
int l = strlen(s);
long long a1 = 0, a2 = 0, b1 = 0, b2 = 0, e = 0, o = 0;
for (int i = 0; i < l; i++) {
if (s[i] == 'a') {
if (i % 2) {
a1++;
o += a1;
e ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
istringstream test(str);
string word;
string num;
int number;
stack<pair<string, int>> s;
vector<vector<string>> v;
int depth = 0;
while (getline(test, word, ',')) {
getline(test, num, ',');
number = stoi(num)... | 5 |
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <c... | 0 |
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
bool arr[26];
string ip;
string op;
cin >> ip;
op = "YES";
if (ip[0] != 'a') {
cout << "NO" << endl;
exit(0);
} else {
int maxi = 'a';
for (int i = 1; i < ip.length(); i++) {
if (ip[i] > maxi + 1) {
op = "NO";
}... | 2 |
#include<bits/stdc++.h>
using namespace std;
int main(){
int a, b;
cin >> a >> b;
int A[101][101]={0};
for(int i=0;i<a;i++){
for(int j = 0; j <b;j++){
cin >> A[i][j];
A[i][b] += A[i][j];
A[a][j] += A[i][j];
A[a][b] += A[i][j];
}
}
for(int i = 0; i<=a;i++){
... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000009LL;
long long large = 2000000000000000000LL;
const long double pi = acos(-1.0);
const long double eps = 1e-10;
struct Vector {
long double x, y;
Vector(long double x = 0, long double y = 0) : x(x), y(y) {}
void init(long double a, long double... | 5 |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 2e5 + 10;
int main()
{
int n; cin>>n;
int a[MAX]; int ans=0;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++){
if(a[i] == i+1){
swap(a[i],a[i+1]); ans++;
}
}
cout<<ans;
}
// abcab | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long LINF = (long long)1e18 + 47;
const int INF = 1e9 + 47;
const int MOD = 998244353;
const int modulo = 1e8;
const int nax = 2 * (int)1e5 + 10;
const double EPS = 1e-9;
const double PI = acos(-1.0);
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
long long int n, j, k;
cin >> n;
string s, ans = "", ans2 = "";
cin >> s;
for (j = 0; j < n; ++j)
if (s[j] == '1')
brea... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
vector<int> a;
int vis[maxn];
int fin[maxn];
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int k;
... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const int INF = 0x3f3f3f3f;
int sg[N][3][3];
int vis[N << 4];
pair<int, int> p[N];
int main() {
ios ::sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = (int)(1); i <= (int)(m); ++i) {
cin >> p[i].first >> p[i].second;
p[i].first--,... | 3 |
#include <bits/stdc++.h>
using namespace std;
struct data {
long long l, r, a, s;
} t[4 * 150100];
long long x[150100], p[150100], n, a[150100], m, c;
data ini(long long val) {
data a;
a.l = a.r = a.a = (val > 0 ? val : 0);
a.s = val;
return a;
}
data comb(data l, data r) {
data z;
z.l = max(l.l, (l.s + r... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long n, k, c;
long long ucln(long long a, long long b) {
long long r;
while (b != 0) {
r = a % b;
a = b;
b = r;
}
return a;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
long long tam = 1;
while (n--) {
cin >> ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, par;
int x[2001], y[2001];
map<pair<int, int>, int> a;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i];
cin >> y[i];
for (int j = 1; j < i; j++) par += a[make_pair(x[i] + x[j], y[i] + y[j])]++;
}
cout << par;
}
| 4 |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 20, SQ = 350;
int ext[SQ][SQ], jumps[SQ][SQ];
int p[MXN];
int n, q;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> n >> q;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
for (int i = n - 1; i >= 0; i--) {
if (i + p[i... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int N = 55, mod = 1000000007;
int dp[N][N][N][N], n, c[N], pw[N], jo;
void upd(int& x) {
if (x >= mod) x -= mod;
}
int main() {
scanf("%d%d", &n, &jo);
pw[0] = 1;
for (int i = 1; i <= n; i++) {
scanf("%d", &c[i]);
pw[i] = pw[i - 1] * 2 % mod;
}
dp[... | 5 |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const long long P = 1e17 + 3;
const int N = 18 + 2, K = 128 + 2, H = 23;
double w[4] = {1. / 6, 1. / 6, 1. / 3, 1. / 3};
unordered_map<long long, double> mp;
long long h, pwr[K] = {1};
int n, a[N][3], ted[N];
void _sum(long long &a, long long b) {
... | 5 |
#include <iostream>
using namespace std;
int mtoi(const string& str)
{
int res = 0,temp = 1;
for (int j = 0; j < str.length(); j++) {
if(str[j] >= '0' && str[j] <= '9')
temp = (int)(str[j] - '0');
else if (str[j] == 'i') {
res += temp;
temp = 1;
}
else if (str[j] == 'x') {
res += temp * 10;
te... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
vector<pair<long long, long long>> adj[101];
map<pair<long long, long long>, long long> mp;
map<long long, long long> ans;
long long start, dest;
void dfs(long long node, long long col) {
mp[{node, col}] = 1;
if (node == dest) ans[col]++;
... | 4 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin>>s;
if(s[0]==s[s.size()-1]){
if(s.size()%2==1) printf("Second");
else printf("First");
}
else {
if(s.size()%2==1) printf("First");
else printf("Second");
}
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const long long cy[] = {1,
60,
300,
1500,
15000,
150000,
1500000,
15000000,
150000... | 5 |
#include <bits/stdc++.h>
using namespace std;
inline char gc() {
static char now[1 << 16], *S, *T;
if (T == S) {
T = (S = now) + fread(now, 1, 1 << 16, stdin);
if (T == S) return EOF;
}
return *S++;
}
inline int read() {
int x = 0, f = 1;
char ch = gc();
while (!isdigit(ch)) {
if (ch == '-') f... | 6 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
int x[220], y[220];
int tw[220];
int mod = 998244353;
signed ma... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
ios_base::sync_with_stdio(false);
long long r, g;
cin >> r >> g;
long long sum = r + g;
long long h = 0;
for (long long i = 1; i <= r + g + 1; i++) {
if ((i * (i + 1)) / 2 > sum) {
h = i - 1;
break;
}
... | 4 |
#include <bits/stdc++.h>
using namespace std;
vector<string> a;
vector<pair<string, pair<vector<long long>, vector<long long>>>> widgets;
vector<pair<string, string>> edges;
long long used[100500];
void createWidget(string s, long long x, long long y) {
vector<long long> xx;
vector<long long> yy;
xx.push_back(0);... | 2 |
#include <bits/stdc++.h>
using namespace std;
int p, q, n, m;
int c[110];
int d[110];
char a[110], b[110];
int main() {
scanf("%d%d", &p, &q);
scanf("%s", a + 1);
scanf("%s", b + 1);
n = strlen(a + 1);
m = strlen(b + 1);
for (int i = 1; i <= m; i++) {
int k = i;
for (int j = 1; j <= n; j++) {
... | 4 |
#include <bits/stdc++.h>
using namespace std;
int N;
double pEatenBy[18][1 << 18];
double a[18][18];
double dp[1 << 18];
int pows[1 << 18];
double getVals(int i, int m) {
if (m == 0) return 0;
int mone = m & (~(m - 1));
int ind = pows[mone];
return pEatenBy[i][m] < -0.5
? pEatenBy[i][m] = a[ind][i]... | 5 |
#include <bits/stdc++.h>
using namespace std;
signed main() {
string s;
cin >> s;
long long n = s.length();
vector<long long> fibo(n + 1, 0);
fibo[1] = 1;
fibo[2] = 2;
for (long long i = 3; i <= n; i++) {
fibo[i] = (fibo[i - 1] + fibo[i - 2]) % 1000000007;
}
bool chk = false;
for (long long i = ... | 3 |
#include <iostream>
#include <vector>
#define int long long
using namespace std;
struct node {
int i, j;
node *left, *right;
int val, lazy;
};
vector<int> a;
node* build(int i, int j) {
if (i == j) {
return new node{i, j, nullptr, nullptr, a[i], 0};
}
node *left = build(i, (i + j) / 2);
node *ri... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, k, v, cnt, mx;
unordered_map<int, int> frq, play, cost;
int mem[600][6000];
int dp(int i, int sum) {
if (i == cnt) {
return 0;
}
int& ret = mem[i][sum];
if (~ret) return ret;
ret = 0;
for (int j = 1; j <= k; j++) {
if (sum - j >= 0) {
ret = ... | 6 |
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
int a;
cin >> a;
cout << (a-30)/2 << endl;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, co = 0;
cin >> x;
for (int n = 1; n <= x; n++) {
for (int m = n; m <= x; m++) {
double a = sqrt(n * n + m * m);
if (floor(a) == ceil(a) && (a <= x)) {
co++;
}
}
}
cout << " " << co << endl;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 35005, K = 55;
int dp[N][K];
int seg[N << 2], push[N << 2], a[N], prv[N], tmp[N];
void pusher(int id) {
seg[id << 1] += push[id];
seg[id << 1 | 1] += push[id];
push[id << 1] += push[id];
push[id << 1 | 1] += push[id];
push[id] = 0;
}
void up(int val,... | 4 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rng(1477);
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
ll res = 0;
int neg = 0, pos = 0, zer = 0;
for (int i = 0; i < n; ++i) {
int t;
cin >> t;
if (t < 0) {
res += -t - 1;
++... | 2 |
#include<bits/stdc++.h>
using namespace std;
int c=0;
int main()
{
int n;
string s;
cin>>n>>s;
for (int i=0;i<n;i++)
if (s[i]=='R') c++;
if (c*2>n) puts("Yes");
else puts("No");
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long double EPS = 1e-9;
long long n, m;
vector<bool> used_l, used_s;
bool dfs(long long i, long long j, vector<vector<char>> &r,
vector<vector<char>> &v, bool line) {
if ((line && used_l[i]) || (!line && used_s[j])) {
return ... | 1 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, i, j;
cin >> n;
string s;
cin >> s;
cout << n + 1 << endl;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long, long long>, int> > P;
bool notsameline(int p) {
long long x1 = P[0].first.first, y1 = P[0].first.second;
long long x2 = P[1].first.first, y2 = P[1].first.second;
long long x3 = P[p].first.first, y3 = P[p].first.second;
if (x1 * (y2 - y3) ... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
template <typename T>
class Fenwick {
private:
vector<T> array;
int n;
public:
Fenwick(int a) {
n = a;
array.resize(n + 10, 0);
}
void put(int idx, T val) {
if (idx >= n || idx < 0) {
cout << "Out of range";
exit(1)... | 2 |
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
class PMA {
PMA* next[256];
vector<ll> matched;
PMA() { REP(i, 0, 256) next[i] = NULL; }
void build(vector<string> &p) {
REP(i, 0, 256) next[i] = NULL;
... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long a, b, sum, uc, x, y, c[100005];
vector<long long> veca, vecb;
set<long long> myset;
int main() {
cin >> a >> b;
while (sum < a + b) {
uc++;
sum += uc;
if (sum <= a + b) c[uc] = uc;
}
x = uc;
while ((a > 0) && (uc > 0)) {
if (c[uc] != 0) {... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int ans = 0;
int pre = 0;
int uku = 0;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == 'R')
uku++;
else
uku--;
if (uku % 4 == 0) {
if (uku > pre) ans++;
pre = uku;
}
}
cout << ans ... | 0 |
#include <bits/stdc++.h>
using namespace std;
int best[2][100010];
char s[2][100010];
queue<int> qu;
int main() {
int i, j, n, k, res;
scanf("%d %d ", &n, &k);
scanf("%s %s ", s[0], s[1]);
memset(best, 9, sizeof(best));
best[0][0] = 0;
qu.push(0);
qu.push(0);
res = 0;
while (!res && !qu.empty()) {
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
for(int i = 1;i <= 9; ++i){
if(a/i <= 9 && (a/i) * i == a){
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
return 0;
} | 0 |
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <complex>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EPS 1e-12
using namespace std;
typedef complex<double> C;
const doub... | 0 |
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <numeric>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<vector<lli> > mat;
const lli MOD = 1000000007;
lli n,k;
vll d;
vll dp;
lli ans = 0;
lli pow(lli a,lli n,lli mod... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int a[n + 1];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long dp[n];
dp[0] = 1;
long long ans = 1;
for (int i = 1; i < n; i++) {
if (a[i] > a[i - 1]) {
dp[i] = dp[i - 1] + 1;
} else... | 1 |
#include <iostream>
#include <fstream>
#include <algorithm>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
ll num[mx];
int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n;
cin>>n;
for(ll i=0;i<n;i++) cin>>num[i];
ll qn;
cin>>qn;... | 0 |
#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
x = 0;
char c = getchar();
while (!isdigit(c)) c = getchar();
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
}
using namespace std;
inline void MIN(int &a, int b) {
if (b < a) a = b;
}
inline void MAX(... | 4 |
#include <bits/stdc++.h>
int main() {
int n, k, i, j;
int hols, arr[1000];
int temp, loop, flag = 0;
scanf("%d%d", &n, &k);
scanf("%d", &hols);
for (i = 0; i <= n; i++) {
arr[i] = 0;
}
for (i = 0; i < hols; i++) {
scanf("%d", &temp);
arr[temp] = 2;
}
for (i = 0; i <= n;) {
for (j = i... | 1 |
#include <bits/stdc++.h>
const long long int mod = 1000 * 1000 * 1000 + 7;
long long int clean(long long int x) {
x %= mod;
if (x < 0) x += mod;
return x;
}
long long int power(long long int x, long long int n) {
if (n == 0) return 1;
x = clean(x);
long long int half = power(x, n / 2);
if (n % 2 == 0)
... | 5 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int mod = (1e9) + 7;
const double eps = 1e-10;
const int siz = 3e5 + 5;
int n, m, k, cur, ans[siz];
struct edge {
int v, w, i;
};
vector<edge> adj[siz];
bool intree[siz];
long long dis[siz];
struct msel {
long long d;
int e, u;
};
stru... | 4 |
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int q,i,j,x,y;
cin>>q;
int a[100005],b[100005],c[100005];
for(i=2;i<=100000;i++)
a[i]=1;
for(i=2;i<=int(sqrt(100000));i++)
{
if(a[i]==1)
for(j=i+i;j<=100000;j+=i)
a[j]=0;
}
b[0]=0;
b[1]=0;
for(i=3;i<=100000;i+... | 0 |
#include <bits/stdc++.h>
using namespace std;
template <typename __T1, typename __T2>
ostream &operator<<(ostream &out, pair<__T1, __T2> &__VAR) {
cout << "[" << __VAR.first << ", " << __VAR.second << "]";
return out;
}
template <typename __T>
ostream &operator<<(ostream &out, vector<__T> &__VAR) {
cout << "[";
... | 3 |
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
vector<int> point[100001];
int n,x,y,siz[100001],son[100001];
bool check[100001];
void dfs1(int u,int f){siz[u]=1;for(int v:point[u])if(v!=f)dfs1(v,u),siz[u]+=siz[v];}
void dfs2(int u,int f){
for(int v:point[u])if(v!=f){dfs2(v,u);if(siz[v]>0... | 0 |
#include <bits/stdc++.h>
using namespace std;
long long expo(long long base, long long exponent, long long mod) {
long long ans = 1;
while (exponent != 0) {
if ((exponent & 1) == 1) {
ans = ans * base;
ans = ans % mod;
}
base = base * base;
base %= mod;
exponent >>= 1;
}
return a... | 4 |
#include<cstdio>
int main()
{
int N,x;
scanf("%d",&N);
x = N * (N + 1) * 0.5;
printf("%d",x);
return 0;
}
| 0 |
#include <bits/stdc++.h>
using namespace std;
int N, A, B;
int P[100000];
set<int> all;
map<int, int> rev;
map<int, vector<int>> adj;
vector<int> one;
char ans[100000];
int main() {
scanf("%d%d%d", &N, &A, &B);
for (int i = 0; i < N; i++)
scanf("%d", P + i), all.insert(P[i]), rev[P[i]] = i;
if (A == B) {
... | 2 |
#include<iostream>
#include<cstdio>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
string a;
int b=0,c=0,d=0;
cin>>a;
for(int i=0;i<a.size();i++){
if(a[i]-'0'>=0&&a[i]-'0'<=9)b++;
if(isupper(a[i]))c++;
if(islower(a[i]))d++;
}
if(b==0||c==0||d==0||a.size()<6)printf("IN");
p... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 1e5 + 10, MaxH = 60;
inline int read() {
char c = getchar();
int x = 0, f = 1;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int ... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.