solution stringlengths 52 181k | difficulty int64 0 6 |
|---|---|
#include <bits/stdc++.h>
using namespace std;
long long n, r1, c1, r2, c2;
vector<string> s;
long long vis[51][51];
vector<pair<long long, long long> > pp{
{-1ll, 0ll}, {1ll, 0ll}, {0ll, 1ll}, {0ll, -1ll}};
vector<pair<long long, long long> > bfs(long long lx, long long ly) {
vector<pair<long long, long long> > a... | 3 |
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 25005;
int n, m, a[N];
int lu[N], ld[N], ru[N], rd[N];
int lp[N], rp[N], ans;
void upt(int l, int r) {
for(int i = l; i <= r; i++) {
for(int &j = lp[i]; j >= l; j--) {
if(a[j] > a[i]) {
int &k = lu[i];
if(a[j]... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 101;
const int MAXM = 20;
const long long INF = 1LL << 61;
struct person {
int monitors, solve;
long long cost;
person() {
monitors = solve = 0;
cost = 0;
}
person(int _monitors, int _solve, long long _cost) {
monitors = _monitors;
... | 2 |
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,x=1;
cin>>n;
if(n==3)
{
cout<<2<<endl<<3<<" "<<2<<endl<<3<<" "<<2<<endl;
continue;
}
if(n>10)
{
while(pow(8,x)<n)
x++;
cout<<n-1+x<<endl;
for(int ... | 4 |
#include <bits/stdc++.h>
using namespace std;
int n, k, a[100005], b[100005], q;
vector<int> ke[100005], t[100005 * 4];
void setup() {
cin >> n >> k;
for (long long i = (1); i <= (n); i++) {
cin >> a[i];
ke[a[i]].push_back(i);
}
}
void add(int x) {
int y = x * 2, z = x * 2 + 1;
int i = 0, j = 0, cnt =... | 5 |
#include <bits/stdc++.h>
using namespace std;
const double pi(3.14159265358979);
int row[1010], col[1010];
int main() {
int i, j, cnt, n, m, ans;
scanf("%d", &m);
scanf("%d", &n);
char a[1010][1010];
for (i = 0; i < m; i++) scanf("%s", &a[i]);
for (i = 0; i < m; i++) {
for (j = 0; j < n; j++)
if (... | 2 |
#include <bits/stdc++.h>
int main() {
int n, k;
scanf("%d %d", &n, &k);
if (n % k == 0)
printf("%d", n + k);
else {
printf("%d", n + (k - (n % k)));
}
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int H, W;
bitset<100> field;
bitset<100> zeros;
int carpet[15][15];
int baseans;
int ans;
vector<bitset<100>>... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j;
string in, out;
cin >> n;
cin >> in;
for (i = 0; i < in.length(); i++) out += '9';
for (j = 0; j < in.length(); j++) {
string s;
int x = (10 - (in[j] - '0')) % 10;
for (i = j; i != (j - 1 + in.length()) % in.length();
... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 100, INF = 1000 * 1000 * 1000;
int dp[N], b[N], ans[N], seg[4 * N], n, t[4 * N];
vector<int> num[N];
vector<pair<int, int> > q[N];
void upd(int p, int val, int s = 0, int e = n, int id = 1) {
if (e - s == 1) {
seg[id] = val;
return;
}
... | 4 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize "trapv"
void solve() {
long long int a, b, c;
cin >> a >> b >> c;
long long int x = c + a + b - 2;
cout << x;
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
;
long long int t;
cin >> t;
while (t--) {
... | 1 |
#include <bits/stdc++.h>
using namespace std;
int n, now, sfeefw;
long long ans;
int rnk[22 + 1][500005], bal[500005], tot[500005];
pair<pair<int, int>, int> sa[500005];
vector<int> v[2 * 500005];
char s[500005];
int total(int ind, int sz) {
auto it1 = prev(upper_bound(v[bal[ind] - 1 + 500005].begin(),
... | 6 |
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;
const int N = 1000000;
int n;
pair<int, int> a1[N];
pair<int, int> a2[N];
int n1, n2;
char s[N + 1];
bool test(pair<int, int> *a, int n)
{
sort(a, a + n);
int p = 0;
for (int i = 0; i < n; ++i) {
if (a[i].first > p) return false;
p... | 0 |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
const int N = 1e5 + 5;
int t[2][N];
void up(int i, int p, int v) {
if (p <= 0) return;
for (; p < N; p += p & (-p)) {
t[i][p] = max(t[i][p], v);
}
}
int qry(int i, int p) {
if (p <= 0) return 0;
... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long mp[27][27];
char s[110];
long long n;
long long mem[101][101][27];
long long dp(long long cur, long long k, long long pre) {
if (k < 0) return -1000000007;
if (n == cur) return 0;
long long &ret = mem[cur][k][pre], x = s[cur] - 'a' + 1;
if (ret != -1000000... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 2010;
const unsigned long long base = 234323;
unsigned long long p[maxn] = {};
unsigned long long h[maxn] = {};
unsigned long long gethash(int i, int j) {
unsigned long long ans = ... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[50];
int b[50];
int score[51][51][51][51][2][2];
int memo[51][51][51][51][2];
bool check[51][51][51][51][2];
int getPassScore(int i, int j, int beforeI, int beforeJ, int turn, int player){
if(i == beforeI && j == beforeJ){
return 0;
}
... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main(void){
int n,t; cin>>n>>t;
int ans =10000;
for(int i=0;i<n;i++){
int c,t1; cin>>c>>t1;
if(ans>c&&t1<=t) ans=c;
}
if(ans!=10000) cout<<ans<<endl;
else
cout<<"TLE"<<endl;
} | 0 |
#include <iostream>
#include <vector>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;
int digit(int n, int d) {
int m = (int)(n/pow(10,d)) * pow(10,d);
return (n - m)/pow(10,d-1);
}
int check_digit(int n) {
for (int i = 15; i > 0; i--) {
if (digit(n, i) > 0) {
return i;
}
}
return 1;
}... | 0 |
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
void solve() {
long long int n, a;
cin >> n;
long long int val = n / 2;
long long int ans = 0, beg = 3;
for (long long int i = 1; i <= val; i++) {
ans += i * (2 * beg + 2 * (beg - 2));
beg += 2;
}
cout << ans << endl;... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5 + 10, MOD = 1e9 + 7;
int f, w, h, fact[MN], lfac[MN];
int bpw(int a, int b) {
if (!b) return 1;
int t = bpw(a, b / 2);
t = 1ll * t * t % MOD;
if (b & 1) return 1ll * a * t % MOD;
return t;
}
int get(int a, int b) {
if (a == 0 && b == 0) return... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) ... | 1 |
#include <bits/stdc++.h>
using namespace std;
int a[1005], b[1005], c[1005];
int main() {
int t, n, i, s;
cin >> t;
while (t--) {
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i] >> b[i];
c[1] = a[1];
for (i = 2, s = a[1] + 1; i <= n; i++, s++) {
if (b[i] >= s) {
if (a[i] >= s) {
... | 2 |
#include <bits/stdc++.h>
using namespace std;
vector<int> lst;
void gen(long long n) {
if (n > 1000000000) return;
if (n > 0) lst.push_back(n);
gen(n * 10 + 4);
gen(n * 10 + 7);
}
int L1, R1, L2, R2, k;
double f(double x, double y, double L, double R) {
return max(0.0, min(R, y) - max(L, x) + 1);
}
double cal... | 2 |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50 + 7;
const int MAX_K = 2000 + 7;
const int INF = 0x3f3f3f3f;
int N;
int A[MAX_N];
char B[MAX_N];
int dp[MAX_N][MAX_K];
int dfs(int n, int k) {
k -= A[n];
if (k <= 0) return 0;
int &res = dp[n][k];
if (res != -1) return res;
res = INF;
for (i... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long mod = 10000000000;
int main() {
long long t;
cin >> t;
while (t--) {
string s;
cin >> s;
int ans = 0, n = s.length();
if (n <= 1)
cout << ans << endl;
else {
int st = -1, ed = -1;
for (int i = 0; i < n; i++) {
if... | 1 |
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
const int inf = 1000000009;
int dfs(vector<vector<int>> &graph, bitset<101> &used, int flow, int pos, int t) {
if (pos == t) return flow;
for (int i=0; i<graph[pos].size(); i++) {
if (u... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin >> t;
while (t--) {
int ans = 0;
cin >> n;
cout << n / 2 << endl;
}
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void scan(T &...args) {
((cin >> args), ...);
}
template <typename... T>
void print(T... args) {
((cout << args), ...);
}
class Solution_To_Problem {
int r, g, b, m, ans;
array<pair<char, int>, 3> count;
public:
void solution_function() ... | 1 |
#include <bits/stdc++.h>
using namespace std;
char in[10];
int main() {
int n;
cin >> n;
long long h = 1LL;
long long w = 1LL;
for (int i = 0; i < n; ++i) {
scanf("%s", in);
string txt = in;
if (txt == "UR" || txt == "DL") {
++h;
} else if (txt == "UL" || txt == "DR") {
++w;
} ... | 1 |
#include <bits/stdc++.h>
using namespace std;
int N, K, A[1 << 11], dp[2][1 << 11];
bool pos(int g) {
if (g < 0) return false;
memset(dp, 0, sizeof dp);
for (int i = (1); i <= (N); i++)
for (int j = (0); j <= (N - i); j++)
if (i + j < N && abs(A[i + j] - A[i - 1]) > (long long)g * (j + 1))
dp[i ... | 4 |
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ... | 0 |
#include <cstdio>
using namespace std;
const int MOD = 1000000007;
int main() {
int n, m;
scanf("%d%d", &n, &m);
long long x[100000], y[100000];
long long xl = 0, yl = 0;
for(int i=0;i<n;i++) {
scanf("%lld", x+i);
if (i!=0) {
xl += (x[i] - x[i-1]) * (n-i) * (i);
... | 0 |
#include <bits/stdc++.h>
using namespace std;
#define MAXN 300010
int n, a[MAXN];
int ans[2];
int f[1000010], p[1000010];
vector<int> adj;
void prime(){
for(int i = 2; i <= 1000000; ++i){
if(!f[i]) p[++p[0]] = i, f[i] = i;
for(int j = 1; j <= p[0] && 1ll * p[j] * i <= 1000000; ++j){
... | 2 |
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define NUM 55
int length;
char S[NUM],T[NUM];
void func(){
scanf("%s %s",S,T);
for(length = 0; ... | 0 |
#include <bits/stdc++.h>
using namespace std;
int64_t N = 1e9 + 7;
int64_t M = 9223372036854775807;
int GCD(int A, int B) {
if (B == 0)
return A;
else
return GCD(B, A % B);
}
bool isPrime(long long n) {
if (n <= 1) {
return false;
}
if (n <= 3) {
return true;
}
if (n % 2 == 0 || n % 3 == 0... | 1 |
#include <bits/stdc++.h>
using namespace std;
vector<int> prime_sieve(int n) {
vector<bool> a(n + 1, 1);
for (int i = 2; i * i <= n; i++) {
if (a[i]) {
for (int j = i * i; j <= n; j += i) a[j] = 0;
}
}
vector<int> res;
for (int i = 2; i <= n; i++) {
if (a[i]) res.push_back(i);
}
return r... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, mod = 1e9 + 7;
long long n, k, q;
long long dp[N][2];
vector<pair<long long, long long> > adj[N];
void dfs(int v, int par = -1) {
dp[v][0] = dp[v][1] = 0;
long long sum = 0;
vector<long long> c;
for (auto x : adj[v]) {
long long u = x.fir... | 3 |
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
#define int long long
#define inf 3000000000000
typedef pair<int, int>P;
int dp[160][10][80];
vector<P>s[160];//P(??????,???????????????)
void init(int m) {
for (int i = 0; i < 160; i++) {
s[i].clear();
for... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a[100005], dp[100005], b[100005];
int n, ans, maxx;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
b[a[i]] = i;
}
memset(dp, 0, sizeof(b));
b[0] = 0;
ans = 1;
for (int i = 1; i <= n; i++) {
if (b[i - 1] < b[i])
dp[i... | 1 |
#include <bits/stdc++.h>
using namespace std;
void solve(long long n, long long d) {
long long i;
if (d <= n) {
cout << "YES" << endl;
return;
}
for (i = 1; i <= n; i++) {
long long x = i + ceil(1.0 * d / (i + 1));
if (x <= n) {
cout << "YES" << endl;
return;
}
}
cout << "NO"... | 1 |
#include <bits/stdc++.h>
using namespace std;
int t, n, mp[21][21];
char a[100010], b[100010];
int main() {
cin >> t;
while (t--) {
cin >> n;
scanf("%s%s", a + 1, b + 1);
int flg = 0;
memset(mp, 0, sizeof(mp));
for (int i = 1; i <= n; i++) {
if (a[i] == b[i]) {
continue;
}
... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int a[2] = {0};
for (int i = 0; i < n; i++) {
a[s[i] - '0']++;
}
cout << n - min(a[0], a[1]) * 2 << endl;
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
return (a / gcd<T>(a, b) * b);
}
template <class T>
inline bool read(T &x) {
int c = getchar();
int sgn = 1;
while (~c && c < '0' || c > '9') {
... | 6 |
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#in... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
int p = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) p += v[i] > v[j];
cout << p % 2 + p / 2 * 4 << endl;
}
| 4 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1005;
int ar[N][N], row[N], col[N], n, m, k, a, b;
char t;
void solve() {
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
row[i] = i;
for (int j = 1; j <= m; j++) {
col[j] = j;
cin >> ar[i][j];
}
}
while (k--) {
cin... | 2 |
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int A[N+1];
int GCD(int a,int b){
return b==0?a:GCD(b,a%b);
}
int main(){
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n,tmp,gcd=0;
cin>>n;
for(int i=0;i<n;++i){
cin>>tmp;
++A[tmp];
gcd=GCD(tmp,gcd);
}
//pairwise
for(int i=2;... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
string str;
stack<string> chat;
map<string, int> check;
cin >> n;
while (n--) {
cin >> str;
chat.push(str);
check[str] = 1;
}
while (!chat.empty()) {
if (check[chat.top(... | 2 |
#include <bits/stdc++.h>
using namespace std;
double x[10000], y[10000], q[100000];
int r[100000];
int main() {
int i, j, n, mj, s = 0;
double m, m1, m2, m3, c = 0;
cin >> n >> s;
for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
for (i = 0; i < n; i++) {
q[i] = sqrt((x[i] - 0) * (x[i] - 0) + (y[i] - 0... | 2 |
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int N=2333;
struct edge{int to,nxt,w,cost;}a[N<<5];
int n,S,T,hd[N],cnt=1,vis[N],pe[N];long long dis[N],ans;
queue<int>Q;
void link(int u,int v,int w,int cost){
a[++cnt]=(edge){v,hd[u],w,cost};hd[u]=cnt;
a[++cnt]=(edge){... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (n % 2 == 1) {
cout << 7;
n -= 3;
}
for (int i = 0; i < (n / 2); i++) cout << 1;
cout << endl;
}
return 0;
}
| 1 |
#include <bits/stdc++.h>
using namespace std;
struct Pnt {
long double x;
long double y;
Pnt(long double x, long double y) : x(x), y(y) {}
Pnt() : x(0), y(0) {}
long double operator%(Pnt p) const { return x * p.y - y * p.x; }
long double len2() const { return x * x + y * y; }
long double len() const { ret... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = numeric_limits<long long>::max();
const long long nax = (long long)(100001);
const long long mod = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
lon... | 1 |
#include <bits/stdc++.h>
using namespace std;
inline int ma(int a, int b) { return ((a - b > 0) ? a : b); }
inline int mi(int a, int b) { return ((a - b > 0) ? b : a); }
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Arg... | 4 |
#include <bits/stdc++.h>
using namespace std;
double probability_mass_function(vector<double> probabilities, long long k) {
const double pi = acos(-1);
const complex<double> I(0, 1);
long long n = probabilities.size();
complex<double> C = exp(2.0 * I * pi / (n + 1.0));
complex<double> answer(0, 0);
for (lon... | 4 |
#include <bits/stdc++.h>
using namespace std;
int arr[10000];
int main() {
int n, m, k, i, c = 0;
cin >> n >> m >> k;
for (i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == 1 && m > 0)
m--;
else if (arr[i] == 1)
c++;
if (arr[i] == 2 && k > 0)
k--;
else if (arr[i] == 2 && m > ... | 1 |
#include <bits/stdc++.h>
using namespace std;
inline long long Read() {
long long res = 0, f = 1;
char c;
while (c = getchar(), c < 48 || c > 57)
if (c == '-') f = 0;
do res = (res << 3) + (res << 1) + (c ^ 48);
while (c = getchar(), c >= 48 && c <= 57);
return f ? res : -res;
}
template <class T>
inlin... | 1 |
#include <bits/stdc++.h>
using namespace std;
vector<int> p[4000];
int ans[300000];
int in[4000], out[4000], vis[4000];
char s[300000][4];
int n, cnt;
int js(char ch) {
if (ch >= 'a' && ch <= 'z')
return ch - 'a';
else if (ch >= 'A' && ch <= 'Z')
return ch - 'A' + 26;
else if (ch >= '0' && ch <= '9')
... | 4 |
#include <bits/stdc++.h>
using namespace std;
void require(bool cond, const string& message = "Runtime error") {
if (!cond) {
cerr << message << endl;
assert(false);
}
}
string text;
int L, R;
struct Restriction {
char c;
int l, r;
int lp, rp;
int lcnt, rcnt;
};
ostream& operator<<(ostream& os, cons... | 5 |
#include <bits/stdc++.h>
using namespace std;
int const N = 2200100;
double const PI = acos(-1);
void cmul(double &x, double &y, double cx, double cy) {
double newx = x * cx - y * cy;
y = x * cy + y * cx;
x = newx;
}
double wx[N], wy[N];
int bitrev[N];
void fft(double *x, double *y, int n) {
for (int i = 0; i <... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string S;
cin >> N >> S;
int res = 0;
vector<vector<int>> dp(N+1, vector<int>(N+1, 0));
for(int i=N-1;i>=0;i--){
for(int j=N-1;j>i;j--){
if(S[i] == S[j]){
dp[i][j] = max(dp[i][j], dp[i+1][j+1]+1... | 0 |
#include <bits/stdc++.h>
using namespace std;
int n, m;
char stra[200];
char strb[10];
map<char, set<int>> mapa;
int main() {
scanf("%d", &n);
scanf("%d", &m);
scanf("%s", &stra);
for (int i = 0; i < n; i++) {
mapa[stra[i]].insert(i);
}
int l, r, c1, c2;
for (int i = 0; i < m; i++) {
scanf("%d", &... | 1 |
#include <bits/stdc++.h>
using namespace std;
struct particip {
string name;
int region;
int points;
};
vector<particip> a;
int n, m;
bool smaller(const particip &a, const particip &b) {
if (a.region == b.region) {
return a.points > b.points;
}
return a.region < b.region;
}
int main() {
cin >> n >> m;... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, m, p[100010], a[100010], id[100010], Next[100010], Prev[100010];
set<pair<int, int> > s;
bool cmp(int a, int b) { return p[a] < p[b]; }
int calc(int x, int y) {
if (x == y) return 1e9;
int d = (p[y] - p[x] + m) % m;
if (x > y) d = (d + a[y]) % m;
if (d <= a[x... | 5 |
#include <bits/stdc++.h>
using namespace std;
string s[255] = {
"0\n",
"1\nlea ebx, [2*eax]\n",
"1\nlea ebx, [eax + 2*eax]\n",
"1\nlea ebx, [4*eax]\n",
"1\nlea ebx, [eax + 4*eax]\n",
"2\nlea ebx, [2*eax]\nlea ecx, [ebx + 4*eax]\n",
"2\nlea ebx, [eax + 2*eax]\nlea ecx, [ebx + 4*eax]\n",
"... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
string s;
cin >> s;
int t = 1;
string ans = "";
for (int i = 0; i < n; i += t) {
ans += s[i];
t++;
}
cout << ans << endl;
return 0;
}
| 1 |
#include <cstdio>
#include <algorithm>
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
using namespace std;
const int N0 = 100010;
const int N = 410;
int x[N0], y[N0];
bool g[N][N], v[N];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
Rep(i, m) scanf("%d%d", &x[i]... | 0 |
#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
const int MOD = 1e9 + 7;
int n;
int m;
string str;
int R[N];
int Last[N];
void add(int &a, int b) {
a += b;
if (a < 0) a += MOD;
if (a >= MOD) a -= MOD;
}
int dp[N][N];
int go(int pos, int curr) {
if (pos == n) return 1;
if (curr == m) return 0... | 4 |
#include <bits/stdc++.h>
using namespace std;
long long ans, kq, n;
string s;
int dem;
int main() {
cin >> n;
while (n > 0) {
n--;
cin >> s;
ans = 0;
dem = 0;
for (int j = 0; j <= s.size() - 1; j++) {
if (s[j] == '0')
dem++;
else {
kq = 0;
for (int i = j; i <=... | 3 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double eps = 1e-7;
int w, l, a[MAXN], sum[MAXN];
int main() {
scanf("%d %d", &w, &l);
for (int i = 1; i < w; i++) scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i];
int ans = INF;
for ... | 4 |
#include "bits/stdc++.h"
using namespace std;
int main() {
int N;
cin >> N;
if (N == 2) {
cout << -1 << endl;
return 0;
}
if (N == 3) {
cout << "aa.\n..b\n..b\n";
return 0;
}
if (N == 6) {
cout << "aa....\n..b...\n..b...\n...aa.\n.....b\n.....b\n";
return 0;
}
if (N == 7) {
cout << "aabbcc.\ndde... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
int ans = a * (a - 1) / 2;
cout << ans * 12 + 1;
}
| 2 |
#include <bits/stdc++.h>
using namespace std;
const double E = 1e-6;
const double PI = 2 * acos(0);
struct p3d {
double x, y, z;
p3d() : x(0), y(0), z(0) {}
p3d(double x, double y) : x(x), y(y), z(0) {}
p3d(double x, double y, double z) : x(x), y(y), z(z) {}
p3d operator+(const p3d& o) const { return p3d(x + ... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
char a[n + 1][n + 1];
int ans[n + 1][n + 1];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
ans[i][j] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - k + 1;... | 2 |
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 7, p = 998244353;
int n, k, lim, a[N], b[N], c[N], rev[N], w[N], fac[N], ifac[N];
inline long long pows(long long a, int b) {
long long ans = 1;
while (b > 0) {
if (b & 1) ans = (ans * a) % p;
a = (a * a) % p, b = b >> 1;
}
return a... | 5 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
long long int dp[MAXN][MAXN];
long long int tav[MAXN];
long long int n;
string s;
long long int dtoc(char x) { return x - '0'; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
tav[0] = 1;
for (int i = 1; i < MAXN; i++)... | 5 |
#include <bits/stdc++.h>
using namespace std;
void Solve() {
long long n;
cin >> n;
vector<pair<pair<long long, long long>, long long> > a(n);
vector<long long> ans(n);
for (long long i = 0; i < (n); ++i) {
cin >> a[i].first.first >> a[i].first.second;
a[i].second = i;
if (a[i].first.first < 0) {
... | 3 |
#include <bits/stdc++.h>
const int MAXN = 300005, MOD = 998244353;
inline int add(int x, int y) { return x + y < MOD ? x + y : x + y - MOD; }
inline int dec(int x, int y) { return x - y < 0 ? x - y + MOD : x - y; }
struct Z {
int x;
Z(int x = 0) : x(x) {}
friend Z operator+(const Z& l, const Z& r) { return Z(add(... | 4 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
template <class t>
inline t read(t &x) {
char c = getchar();
bool f = 0;
x = 0;
while (!isdigit(c)) f |= c == '-', c = getchar();
while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = get... | 6 |
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<61LL;
static const int mod = 10007;
typedef pair<int,int> PII;
LL N,K;
LL V[11][2020];
LL Q[11][2020],T[11][2020];
LL mem[2020][11];
LL temp;
LL ca... | 0 |
#include <bits/stdc++.h>
unsigned long long counts[500001] = {0};
char s[500001], t[500001];
int main() {
unsigned long long n, k;
scanf("%llu %llu", &n, &k);
scanf("%s %s", (char *)s, (char *)t);
unsigned long long i;
for (i = 0; i < n && s[i] == t[i]; i++)
;
counts[n] = 1;
counts[n - i] += 1;
unsi... | 5 |
#include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 228228;
const int e[13] = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
string a, o;
string t[13] = {"I", "VI", "V", "XI", "X", "LX", "L",
"CX", "C", "DC", "D", "MC", "M"};
long long s, _s, b, i, j, n... | 3 |
#include <bits/stdc++.h>
using namespace std;
long long int n, a[100005], sum = 0, p = 0, s = 0, ans = 0;
bool mark[100005], rang[100005];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
if (sum % 3 == 0) {
sum /= 3;
for (int i = 1; i <= n; i++) {
s += a[i... | 3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, cnt = 0, res = 0;
cin >> n;
string s;
int cnt0 = 0, cnt1 = 0, nt = 0;
for (int i = 0; i < n; i++) {
cin >> s;
cnt0 = 0;
cnt1 = 0;
for (int j = 0; j < s.length(); j++)
... | 2 |
#include <bits/stdc++.h>
using namespace std;
int n, len;
int a[100005], v[100005], dp[2][100005], poz[100005], fact[100005];
inline bool Lucky(int x) {
while (x) {
if (x % 10 != 4 && x % 10 != 7) return false;
x /= 10;
}
return true;
}
inline int Pow_Log(int x, int p) {
int sol = 1;
while (p) {
i... | 5 |
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
int main() {
ios_base::sync_with_stdio(0);
string a, b;
cin >> a >> b;
int tab1[26], tab2[26];
for (int i = int(0); i < int(26); ++i) {
tab1[i] = tab2[i] = 0;
}
for (int i = int(0)... | 2 |
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef uns... | 0 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1... | 2 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 1e5 + 9;
ll gcd(ll a, ll b) {
if (a == 0) return b;
return gcd(b % a, a);
}
int main() {
ios::sync_with_stdio(false);
ll a;
cin >> a;
ll b, c, x;
for (int i = 0; i < 5; i++) x = sqrt(a);
for (ll i = sqrt(a); i > 0; i--)... | 3 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a[100005],b,c;
ll ans;
vector<pair<ll,ll>> p;
int main()
{
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<m;i++){
cin>>b>>c;
p.push_back({c,b});
}
sort(p.begin(),p.en... | 0 |
#include <bits/stdc++.h>
using namespace std;
int main()
{
double w,h,x,y;cin>>w>>h>>x>>y;
cout<< fixed<< setprecision(6)<<w*h/2<<" ";
if(w/2==x&&h/2==y)
cout<<1;
else
cout<<0;
}
| 0 |
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,q;
long long ans;
long long a[100000+10],b[100000+10];
int main()
{
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
n++;a[n]=1e18;a[0]=-1e18;
for(int i=1;i<=m;i++)
scanf(... | 0 |
#include <bits/stdc++.h>
using namespace std;
string s, d, h;
int cnt = 1;
char c[6][6], x;
map<string, bool> ch;
vector<int> ind;
void tot(string s) {
if (ch[s]) return;
ch[s] = 1;
string a;
c[0][2] = s[0];
c[2][2] = s[1];
c[1][0] = s[2];
c[1][1] = s[3];
c[1][2] = s[4];
c[1][3] = s[5];
c[3][2] = c[... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
template <typename T>
struct LCT {
int ch[MAXN][2] = {0, 0}, fa[MAXN] = {0}, siz[MAXN] = {0};
bool rev_tag[MAXN];
inline void maintain(int p) { siz[p] = siz[ch[p][0]] + siz[ch[p][1]] + 1; }
inline void lazydown(int p) {
if (rev_tag[p]) {... | 5 |
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, l, c, d, nl, np, p;
scanf("%d%d%d%d%d%d%d%d", &n, &k, &l, &c, &d, &p, &nl, &np);
printf("%d\n", min(min(k * l / nl, c * d), p / np) / n);
return 0;
}
| 1 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
mt19937_64 mt_rand(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
inline bool upmax(T1& a, T2 b) {
return (a < b ? (a = b, true) : false);
}
template <typename... | 1 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E5 + 10;
const int INF = 1 << 30;
struct OPT {
int x, s1, s2, id;
} op[MAXN], tL[MAXN], tR[MAXN];
pair<int, int> p[MAXN];
int n, V, t[MAXN], Ans1[MAXN], Ans2[MAXN];
long long v1[MAXN], v2[MAXN], totv1, totv2, val1[MAXN], val2[MAXN];
void C(int x, int v) ... | 6 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 7;
const int alphabet = 26;
const int inf = INT_MAX;
const long long lint = 1e18 + 9;
inline long long cnm(char ch) { return (ch - '0'); }
inline long long cap(char ch) { return (ch - 'a'); }
inline void instr(string& s,... | 1 |
#include <bits/stdc++.h>
using namespace std;
vector<int> ans[105];
vector<int> lag, kom;
int main() {
int n, m, k;
cin >> n >> m >> k;
lag.resize(m);
kom.resize(k);
for (int i = 0; i < m; cin >> lag[i], i++)
;
for (int i = 0; i < k; cin >> kom[i], i++)
;
int kol = 0;
for (int i = 0; i < m; i++)... | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.