-
-
Save orisano/c36804da478d0b7dd6ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
int n = in(); | |
if (n == 1) cout << 0 << endl; | |
else cout << 1 << endl; | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
int a, b; | |
cin >> a >> b; | |
if (a >= b) cout << "Congratulations!\n"; | |
else cout << "Enjoy another semester...\n"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
ll n, m; | |
cin >> n >> m; | |
cout << n / (m + 1) << endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
int x, y; | |
int n = in(); | |
x = y = 0; | |
for (int i = 0; i < n; i++){ | |
string s; | |
cin >> s; | |
for (const auto& c : s){ | |
if (c == 'X') x += i; | |
if (c == 'Y') y += (n - i - 1); | |
} | |
} | |
if (x == y) cout << "Impossible\n"; | |
else if (x < y) cout << "Y\n"; | |
else cout << "X\n"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
int h, w; | |
cin >> h >> w; | |
int v = 0; | |
for (int i = 0; i < h; i++){ | |
string s; | |
cin >> s; | |
for (const auto& c : s){ | |
if (isdigit(c)) v += c - '0'; | |
} | |
} | |
cout << v << endl; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
struct Solver { | |
Solver(int v) : G(v), vis(v, -1) {} | |
void add_edge(int f, int t){ | |
f--; | |
t--; | |
G[f].push_back(t); | |
G[t].push_back(f); | |
} | |
int solve(int cur=0, int par=-1, int depth=0){ | |
vis[cur] = depth; | |
for (const auto& to : G[cur]){ | |
if (to == par) continue; | |
if (vis[to] >= 0) return vis[cur] - vis[to] + 1; | |
int r = solve(to, cur, depth + 1); | |
if (r >= 0) return r; | |
} | |
return -1; | |
} | |
vector<vector<int>> G; | |
vector<int> vis; | |
}; | |
int main() | |
{ | |
int n; | |
scanf("%d", &n); | |
Solver s(n); | |
for (int i = 0; i < n; i++){ | |
int x, y; | |
scanf("%d%d", &x, &y); | |
s.add_edge(x, y); | |
} | |
printf("%d\n", s.solve()); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type&x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type&x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int dp[20020] = {}; | |
int main() | |
{ | |
int n, m; | |
n = in(), m = in(); | |
dp[0] = 1; | |
for (int i = 0; i < n; i++){ | |
int v = in(); | |
for (int x = 10000; x >= 0; x--){ | |
if (!dp[x]) continue; | |
dp[x + v] = 1; | |
} | |
} | |
for (int i = m; i < 20020; i++){ | |
if (dp[i]){ | |
cout << i << endl; | |
goto END; | |
} | |
} | |
cout << -1 << endl; | |
END:; | |
return 0; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
typedef long double ld; | |
typedef tuple<int, int> duo; | |
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; | |
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; | |
const int Mod = 1000000000 + 0; | |
//{{{ templates | |
#define TT_ template<typename T>inline | |
#define TTF_ template<typename T,typename F>inline | |
TT_ T sq(T x){return x*x;} | |
TT_ T In(){T x;cin>>x;return x;} | |
TT_ void Out(T&x){cout<<x;} | |
TT_ void sort(T&v){sort(begin(v),end(v));} | |
TT_ void revs(T&v){reverse(begin(v),end(v));} | |
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));} | |
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);} | |
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);} | |
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));} | |
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;} | |
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));} | |
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));} | |
inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);} | |
inline int in(){int x;scanf("%d",&x);return x;} | |
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;} | |
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);} | |
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple | |
int main() | |
{ | |
int n, m; | |
n = in(), m = in(); | |
vector<int> v; | |
inpt(v, m, in); | |
int maxi = 0; | |
for (int i = 0; i < m; i++){ | |
maxi = max(maxi, ubnd(v, v[i] + n) - i); | |
} | |
cout << maxi << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment