intさわだんのBlack History

刹那的レジェンドになりたい。

2014-10-08から1日間の記事一覧

POJ(PKU) Ubiquitous Religions

問題概要 学生の数(n)、クエリの数(m)が与えられる。各クエリはn以下の二つの整数があり二人の学生は同じ宗教であることを示している。 学校内で予想できる最大の宗教の数はいくつかもとめる。 解法 Union-Findやるだけ 自分が親であるのをカウント。これも…

POJ(PKU) 1936 ALL in ALL

問題概要 二つの文字列s,tが与えられる。tの任意の文字を削除してsにすることができるか。 s,tは100000文字を超えない。 解法 t[0]からt見ていきs[0]と同じば場合s[1]について比較。 #include <cstdio> #include <iostream> #include <cstring> using namespace std; int main(){ char s</cstring></iostream></cstdio>…

POJ(PKU) 3618 Exploration

やるだけ・ JOI予選っぽい問題だったし一発AC #include <cstdio> #include <algorithm> #include <utility> using namespace std; typedef pair<int,int> P; P p[50003]; int main(){ int n,t; int ans = 0; int d[50003]; scanf("%d%d",&t,&n); for(int i = 0;i < n;i++){ scanf("%d",&d[i]); p[i</int,int></utility></algorithm></cstdio>…

poj 3977

なぜかWAになる こんどまた解き直す。 保存用 #include <cstdio> #include <iostream> #include <algorithm> #include <cstdlib> using namespace std; int n,n2; long long int d[50]; typedef pair<long long int,int> P; P ps[1 << (40 / 2)]; int main(){ while(1){ scanf("%d",&n); if(n == 0)break; for(int i = </long></cstdlib></algorithm></iostream></cstdio>…

第8回日本情報オリンピック 本選 「ピザ」

顕著な二分探索。なんかにぶたん使わなくても解けるらしいのですがややこしそうなので二分探索を使うほうがいいと思います。 #include <cstdio> #include <algorithm> using namespace std; int nau; int t[100003]; int main(){ while(1){ int d,n,m; scanf("%d",&d); if(d == </algorithm></cstdio>…

第8回日本情報オリンピック 本選 「IOIOI」

m解法の詳細は、連続する"IOI"の数を計算する。(たとえば、IOIOIのとき2) その値をtとすると、ans += max(0,t-n+1)で答えが求まる。 少し考えればできる問題。 #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main(){ while(1){ int n,m; char s</iostream></algorithm></cstdio>…