#include<bits/stdc++.h> using namespace std; int main() { int hh, w, t, p; while (cin >> w >> hh >> t >> p, w) { int res[40][40]; for (int i = 0; i < 40; i++) for (int j = 0; j < 40; j++) res[i][j] = 0; for (int i = 0; i < hh; i++) for (int j = 0; j < w;</bits/stdc++.h>…
#include<bits/stdc++.h> using namespace std; int n,m; double dp[(1<<16)][17]; double a[20][20]; double memo(int state,int enemy){ if(enemy==m)return 1; if(state==(1<<n)-1)return 0; if(dp[state][enemy]>=0)return dp[state][enemy]; double &res=dp[state][enemy]; res=0; for(int i=0;i</n)-1)return></bits/stdc++.h>
#include<bits/stdc++.h> using namespace std; /* http://acm-icpc.aitea.net/index.php?plugin=attach&refer=2014/Practice/模擬国内予選/講評&openfile=D.pdf */ const int inf=1e9; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n,m,h,k; while(cin>>n>>m</bits/stdc++.h>…
#include<bits/stdc++.h> #define fi first #define se second typedef long long ll; using namespace std; //幾何ライブラリ //ほぼ、https://ei1333.github.io/algorithm/geometry_new.html からパクりました using Real=double;//問題によってはlong double に変更して</bits/stdc++.h>…
#include<bits/stdc++.h> #define fi first #define se second typedef long long ll; using namespace std; //union_find //_n mast be unsigned int //BEGIN CUT HERE class union_find{ public: explicit union_find(int _n):n(_n){ par.resize(static_cast<unsigned long>(_n)); rank.r</unsigned></bits/stdc++.h>…
#include<bits/stdc++.h> #define fi first #define se second typedef long long ll; using namespace std; bool dp[1001][1001]; int main(){ int n; while(cin>>n,n){ vector<pair<int,int> > v; int sum=0,maxe=0; int sumw=0; int maxw=0; vector<int> vv; for(int i=0;i<n;i++){ int a,b;cin>>a>>b; v.push_bac</n;i++){></int></pair<int,int></bits/stdc++.h>…
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<<x<<"\n" typedef long long ll; using namespace std; const int inf=(int)1e9; vector<vector<pair<int,int> > > v; bool past[801]; bool leaf[801]; void dfs(int now){ bool flag=1; for(int i=0;i<(int)v[now].size();i++…</x<<"\n"></bits/stdc++.h>
#include<bits/stdc++.h> typedef long long ll; using namespace std; const ll inf=(ll)1e14; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed; int n,m; while(cin>>n>>m,n){ ll land[201][201],sea[201][201]; int a[1001]; for(int i=0;i<201;i++){ for(in</fixed;></bits/stdc++.h>…
#include<bits/stdc++.h> using namespace std; int dp[2][(1<<24)]; string s[501]; int n,m; bool a[501][501]; int main(){ while(cin>>n>>m,n){ for(int i=0;i<n;i++){ cin>>s[i]; for(int j=0;j<m;j++){ a[i][j]=(s[i][j]=='1'); } } if(n<=m){ int ans=0; for(int i=0;i<(1<<n);i++){ if(ans>=__builtin_popcount(i))…</m;j++){></n;i++){></bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<<x<<"\n" typedef long long ll; using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; vector<int> x,y,xx,yy; int imos[5011][5011]; …</x<<"\n"></bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<<x<<"\n" typedef long long ll; using namespace std; const int inf=100000000; int n,m,h,w; vector<int> a,b; int dp[1000001],dp2[1000001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); c…</x<<"\n"></bits/stdc++.h>
#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<<x<<"\n" typedef long long ll; using namespace std; class Bit{ public: //tbl[1]...tbl[n] explicit Bit(int n):size(static_cast<unsigned int>(n)){//1-indexed tbl.resize(size+10,0); } //一点のみの更新 void add(int a,ll w)…</x<<"\n"></bits/stdc++.h>
#include<bits/stdc++.h> typedef long long ll; using namespace std; int n,m,h,w; ll dp[(1<<20)]; vector<int> v[20]; int main(){ cin>>n>>m; for(int i=0;i<m;i++){ int x,y;cin>>x>>y;x--;y--; v[y].push_back(x); } dp[0]=1; for(int i=0;i<(1<<(n+1));i++){ if(dp[i]==0)continue; for(int bi</m;i++){></int></bits/stdc++.h>…
//const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; ll n,m,h,w; string s; map<pair<int,int>,ll> mp; int x[100001],y[100001]; ll ans[10]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision</pair<int,int>…
const ll MOD=(ll)1e9+7; const ll inf=(ll)1e14; int n,m,h,w; vector<int> v[100001]; ll f[100001],g[100001]; bool fpast[100001],gpast[100001]; ll Rank[100001]; int r=0; void dfs(int now){ Rank[now]=r; r++; for(int i=0;i<(int)v[now].size();i++){ i</int>…
using namespace std; //const ll MOD=(ll)1e9+7; const ll inf=(ll)1e15; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; ll d[1001]; vector<pair<int,ll> > v[1001]; bool used[1001]; void dfs(int now){ used[now]=1; for(int i=0;i<(in</pair<int,ll>…
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const double PI=acos(-1.0); const double EPS=1e-10; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; ll x[2001],y[2001]; int main(){ ios::sync_…
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; int k,l; class union_find{ public: explicit union_find(int _n):n(_n){ par.resize(static_cast<unsigned long>(_</unsigned>…
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; int n,a; string k; int b[100001]; int num[100001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; int n,k; string v[51],w[51]; int mojisuu[10]; bool check(){ map<char,string> mp; for(int i=0;i</char,string>
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; int n,m,h,w; string s; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<
using namespace std; //const ll MOD=(ll)1e9+7; //const ll inf=(ll)1e14; const int dy[]={1,0,-1}; const int dx[]={1,0,-1}; const double eps=1e-10; int n,m,h,w; string s; double a,b,c; const double PI=acos(-1.0); bool check(double mid){ doub…