# C Archive

## Codeforces Round #429 (Div. 2), problem: (D) Leha and another game about graph Solution In C/C++

#include<cstdio> using namespace std; const int MAXN = 300000+5; const int MAXE = MAXN*2; int to, nxt, head, ne; void addEdge(int f, int t) { to = t; nxt = head; head = ne; } …

## Codeforces Round #429 (Div. 2), problem: (C) Leha and Function Solution In C/C++

#include<bits/stdc++.h> using namespace std; int main(){ std::ios::sync_with_stdio(false); int m; cin>>m; int a,b; for(int i=0;i<m;i++) cin>>a; vector<pair<int,int> >br(m); for(int i=0;i<m;i++){ cin>>b; br=make_pair(b,i); } sort(a,a+m); int ans; sort(br.begin(),br.end()); reverse(br.begin(),br.end()); for(int i=0;i<m;i++) ans.second]=a; for(int i=0;i<m;i++) cout<<ans<<” “; return …

## Codeforces Round #429 (Div. 2), problem: (B) Godsend Solution In C/C++

#include<cstdio> int main() { int n;int t;scanf(“%d”,&n); for(int i=1;i<=n;i++) {scanf(“%d”,&t); if(t%2) { printf(“First”); return 0; } } printf(“Second”); return 0; }

## Codeforces Round #429 (Div. 2), problem: (A) Generous Kefa Solution in C/C++

#include<iostream> using namespace std; int i,j,n,k,a; string s; main(){ for(cin>>n>>k>>s;i<s.size();)a-‘a’]++; for(i=0;j<26;)a>k?i=1:0; cout<<(i?”NO\n”:”YES\n”); }

## Codeforces Round #419 (Div. 2), problem: (B) Karen and Coffee Solution In C/C++

#include <bits/stdc++.h> using namespace std; const int N=200007; int n,k,q,a,b,p,c,i; int main(){ cin>>n>>k>>q; for(i=0;i<n;i++)cin>>a>>b,p++,p–; for(i=1;i<N;i++)p+=p,c+=c+(p>=k); for(i=0;i<q;i++){cin>>a>>b;cout<<c-c<<‘\n’; } }

## Codeforces Round #419 (Div. 2), problem: (A) Karen and Morning Solution In C/C++

#include<bits/stdc++.h> int m,s,t; int main(){ t=0; scanf(“%d:%d”,&m,&s); while(m/10+m%10*10!=s){ s++,t++; if(s>59)m++,s=0; if(m>23)m=0; } printf(“%d\n”,t); }

## Codeforces Round #419 (Div. 1), problem: (E) Karen and Neighborhood Solution In C/C++

#include <bits/stdc++.h> using namespace std; typedef pair<long long,long long> ii; long long n,k,i,w,res; long long m; map <long long,long long> num,f,c; long long get(long long t) { if (f>=0) return f; f=get((t-1)/2)+get(t/2); if (c==1) f++; …

## Codeforces Round #419 (Div. 1), problem: (D) Karen and Cards Solution In C/C++

#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 500010; ll maxn,minn,sum; int n,p,q,r,tot=1,x,y,z; ll ret=0; vector<int> c; void update(int a,int b,int x,int l,int r,int i) { if(a>r || l>b || …

## Codeforces Round #419 (Div. 1), problem: (C) Karen and Supermarket Solution In C/C++

#include<cstdio> #include<algorithm> #include<queue> using namespace std; const int N=5010; int n,m,c,d,fa; int w,head,next; void add(int f,int t){ static int cnt=0; w=t; next=head; head=cnt; } int f,g,size; //f,g表示在子树i中买j件物品的最小代价 //其中g要求购买从根到i的物品 void dfs(int x){ for (int i=1;i<=n;i++) f=g=1e9+1; …

## Codeforces Round #419 (Div. 1), problem: (B) Karen and Test Solution In C/C++

#include <cstdio> #include <iostream> #include <cstring> #include <cstdlib> using namespace std; #define ll long long const int N=200010; const ll M=1000000007ll; ll n,a,e,re; ll suan(ll x,ll y){ ll t=1;while(y){if(y&1)t=t*x%M;x=x*x%M;y>>=1;}return t; } ll work(ll x,ll y){ …