静かで孤独な日記

のんびりたまに

AOJ1625 折り紙(Origami, or the art of folding paper)

#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>…

AOJ 2237 The Castle

#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>

AOJ 2585 1 Day Passport

#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>…

AOJ 2334 Roads on Towns

#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>…

AOJ 2511 Sinking islands

#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>…

AOJ 2510 Twin book report

#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>…

AOJ 2333 My friends are small

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 1196 Bridge Removal

#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>

AOJ 2200 Mr.Rito Post Office

#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>…

AOJ 1619 Making Lunch Boxes

#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>

AOJ 2608 Minus One

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2426 Treasure Hunt

#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>

AOJ 2607 Invest Master

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2629 Manhattan

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2610 Fast Division

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2232 Ennichi

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2583 JAG-channel

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 2600 Koto Distance

#include<bits/stdc++.h> #define fi first #define se second #define show(x) cerr<<#x<<"="<</bits/stdc++.h>

AOJ 1167 ポロック予想

#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>

ABC038-D プレゼント

#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>

ABC041-D 徒競走

#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>…

ABC045 D すぬけ君の塗り絵

//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>…

ABC036-D 塗り絵

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>…

ABC061 D Score Attack

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>…

ABC033 D 三角形の分類

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_…

ABC049 D 連結

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>…

ABC030-D へんてこ辞書

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<

ABC031-D 語呂合わせ

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>

ABC027-D ロボット

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<

ABC026-D 高橋君ボール1号

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…