锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品亚洲综合一区在线观看,亚洲黄色免费,亚洲精品乱码久久久久久蜜桃麻豆 http://www.shnenglu.com/yuziyu/category/10797.html姣忓ぉ榪涙涓鐐圭偣,Coding Everyday!zh-cnFri, 17 Jul 2009 07:55:37 GMTFri, 17 Jul 2009 07:55:37 GMT60USACO 4.1 Fence Loopshttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.htmlYZYYZYFri, 17 Jul 2009 06:26:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.htmlhttp://www.shnenglu.com/yuziyu/comments/90336.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/17/90336.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/90336.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/90336.html闃呰鍏ㄦ枃

YZY 2009-07-17 14:26 鍙戣〃璇勮
]]>
USACO 4.1 Beef McNuggetshttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.htmlYZYYZYSun, 12 Jul 2009 06:58:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.htmlhttp://www.shnenglu.com/yuziyu/comments/89864.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/12/89864.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89864.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89864.html鍏堝皢box榪涜鎺掑簭銆?br />濡傛灉box閲岄潰鐨勬暟鐨勬渶澶у叕綰︽暟涓嶄負1鐨勮瘽錛岄偅涔堟墍鏈夌粍鎴愮殑鏁幫紝鍙彲鑳芥槸榪欎釜鍏害鏁扮殑鍊嶆暟錛屽洜姝ゆ病鏈変笂闄愶紝杈撳嚭涓?.
鐢╨ast璁板綍鏈灝忕殑鈥滀笉鑳界粍鎴愮殑鏁扳濄傝繖鏍峰綋last涔嬪悗鏈塨oxs[0]涓繛緇暟閮藉彲浠ョ粍鎴愮殑璇濓紝閭d箞鎵鏈夌殑鏁伴兘鍙互緇勬垚銆?br />last+1...last+box[0]鍙互緇勬垚鐨勮瘽錛岄偅涔堟瘡涓暟閮藉姞涓涓猙ox[0],閭d箞鏂頒竴杞殑box[0]涓暟涔熷彲浠ョ粍鎴愶紝浠ユ綾繪帹銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"nuggets.in");
ofstream聽fout(
"nuggets.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽box_num;
int聽boxs[10];

bool聽ok[256];

int聽gcd(int聽a,int聽b)
{
聽聽聽聽
if(a<b)聽swap(a,b);

聽聽聽聽
int聽tmp;

聽聽聽聽
while(b!=0){
聽聽聽聽聽聽聽聽tmp聽
=聽a;
聽聽聽聽聽聽聽聽a聽
=聽b;
聽聽聽聽聽聽聽聽b聽
=聽tmp%b;
聽聽聽聽}

聽聽聽聽
return聽a;
}

void聽solve()
{

聽聽聽聽
in>>box_num;
聽聽聽聽
for(int聽i=0;i<box_num;++i)
聽聽聽聽聽聽聽聽
in>>boxs[i];

聽聽聽聽sort(
&boxs[0],&boxs[box_num]);
聽聽聽聽
聽聽聽聽
int聽t聽=聽boxs[0];

聽聽聽聽
for(int聽i=1;i<box_num;++i){
聽聽聽聽聽聽聽聽t聽
=聽gcd(t,boxs[i]);
聽聽聽聽}

聽聽聽聽
if(t!=1){
聽聽聽聽聽聽聽聽
out<<0<<endl;
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}

聽聽聽聽memset(ok,
0,sizeof(ok));

聽聽聽聽
int聽last聽=0;
聽聽聽聽ok[
0]聽=true;
聽聽聽聽
int聽i=0;

聽聽聽聽
while(true){
聽聽聽聽聽聽聽聽
if(ok[i%256]){
聽聽聽聽聽聽聽聽聽聽聽聽ok[i
%256]聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
if(i-last>=boxs[0]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<last<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽x=0;x<box_num;++x){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ok[(i
+boxs[x])%256]聽=true;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽last聽
=聽i;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
++i;
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}


Beef McNuggets

Hubert Chen

Farmer Brown's cows are up in arms, having heard that McDonalds is considering the introduction of a new product: Beef McNuggets. The cows are trying to find any possible way to put such a product in a negative light.

One strategy the cows are pursuing is that of `inferior packaging'. ``Look,'' say the cows, ``if you have Beef McNuggets in boxes of 3, 6, and 10, you can not satisfy a customer who wants 1, 2, 4, 5, 7, 8, 11, 14, or 17 McNuggets. Bad packaging: bad product.''

Help the cows. Given N (the number of packaging options, 1 <= N <= 10), and a set of N positive integers (1 <= i <= 256) that represent the number of nuggets in the various packages, output the largest number of nuggets that can not be purchased by buying nuggets in the given sizes. Print 0 if all possible purchases can be made or if there is no bound to the largest number.

The largest impossible number (if it exists) will be no larger than 2,000,000,000.

PROGRAM NAME: nuggets

INPUT FORMAT

Line 1: N, the number of packaging options
Line 2..N+1: The number of nuggets in one kind of box

SAMPLE INPUT (file nuggets.in)

3
3
6
10

OUTPUT FORMAT

The output file should contain a single line containing a single integer that represents the largest number of nuggets that can not be represented or 0 if all possible purchases can be made or if there is no bound to the largest number.

SAMPLE OUTPUT (file nuggets.out)

17


YZY 2009-07-12 14:58 鍙戣〃璇勮
]]>
USACO 3.4 Raucous Rockershttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.htmlYZYYZYSat, 11 Jul 2009 03:48:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.htmlhttp://www.shnenglu.com/yuziyu/comments/89781.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/11/89781.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89781.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89781.html涓寮濮嬫妸棰樻剰鐞嗚В閿欎簡錛屼互涓哄埢鍦ㄥ悓涓寮犲厜鐩樹笂鐨勬瓕鏇茬殑鏃墮棿欏哄簭涓嶅彉灝卞彲浠ヤ簡銆?br />浜嬪疄涓婁笉浠呭悓鍏夌洏涓婄殑姝屾洸鍐欏叆鏃墮棿瑕佹寜欏哄簭錛屽墠涓寮犲厜鐩樹笂鐨勬瓕鏇蹭笉鑳芥瘮鍚庝竴寮犳瓕鏇插啓鍏ユ椂闂磋鏅氥?br />
鏁版嵁閲忔瘮杈冨皯錛岀敤鍥炴函娉曪紝dp涔熻銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"rockers.in");
ofstream聽fout(
"rockers.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽capacity[20];;
int聽songs[20];
int聽song_num,disk_num;

int聽res聽=0;
int聽cur;

void聽backtracing(int聽depth,int聽last)
{
聽聽聽聽
if(depth==song_num){
聽聽聽聽聽聽聽聽
if(cur>res){
聽聽聽聽聽聽聽聽聽聽聽聽res聽
=聽cur;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}
聽聽聽
聽聽聽 //濡傛灉鍚庨潰鎵鏈夌殑姝屾洸閮藉姞涓婅繕姣旀渶浼樺煎皬錛屽壀鏋?br />聽聽聽聽
if(cur+song_num-depth<=res)
聽聽聽聽聽聽聽
return;聽

聽聽聽聽
for(int聽i=last;i<disk_num;++i){
聽聽聽聽聽聽聽聽 //濡傛灉褰撳墠姝屾洸闇瑕佸埢褰曪紝閭e彧闇鍒誨湪絎竴寮犺兘瑁呭緱涓嬬殑鍏夌洏涓娿?br />聽聽聽聽聽聽聽聽
if(聽capacity[i]>=songs[depth]){
聽聽聽聽聽聽聽聽聽聽聽聽cur
++;
聽聽聽聽聽聽聽聽聽聽聽聽capacity[i]
-=songs[depth];
聽聽聽聽聽聽聽聽聽聽聽聽backtracing(depth
+1,i);
聽聽聽聽聽聽聽聽聽聽聽聽capacity[i]
+=songs[depth];
聽聽聽聽聽聽聽聽聽聽聽聽cur
--;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽 // 涓嶅埢褰撳墠姝屾洸
聽聽聽聽backtracing(depth
+1,last);

}

void聽solve()
{
聽聽聽聽
int聽c;
聽聽聽聽
in>>song_num>>c>>disk_num;

聽聽聽聽
for(int聽i=0;i<song_num;++i)
聽聽聽聽聽聽聽聽
in>>songs[i];

聽聽聽聽
for(int聽i=0;i<disk_num;++i)
聽聽聽聽聽聽聽聽capacity[i]聽
=聽c;

聽聽聽聽backtracing(
0,0);

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-11 11:48 鍙戣〃璇勮
]]>
USACO 3.4 Electric Fencehttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.htmlYZYYZYFri, 10 Jul 2009 14:19:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.htmlhttp://www.shnenglu.com/yuziyu/comments/89761.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89761.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89761.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89761.html
#include聽<iostream>
#include聽
<fstream>
#include聽
<cmath>

usingnamespace聽std;

ifstream聽fin(
"fence9.in");
ofstream聽fout(
"fence9.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

void聽solve()
{
聽聽聽聽
int聽n,m,p;
聽聽聽聽
in>>n>>m>>p;

聽聽聽聽
int聽res聽=0;

聽聽聽聽
int聽s,e;
聽聽聽聽
for(int聽y=1;y<m;++y){
聽聽聽聽聽聽聽聽s聽
=聽n*y/m+1;
聽聽聽聽聽聽聽聽e聽
=聽(聽y*(n-p)%m==0聽)聽?聽(y*(n-p)/m-1+p)聽:聽floor(((double)y*(n-p)/m)+p);
聽聽聽聽聽聽
//聽聽out<<y<<"聽"<<s<<"聽"<<e<<endl;
聽聽聽聽聽聽聽聽res聽+=聽max(0,(e-s+1));
聽聽聽聽}

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-07-10 22:19 鍙戣〃璇勮
]]>
USACO 3.4 American Heritagehttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.htmlYZYYZYFri, 10 Jul 2009 10:51:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.htmlhttp://www.shnenglu.com/yuziyu/comments/89748.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/10/89748.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89748.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89748.html闃呰鍏ㄦ枃

YZY 2009-07-10 18:51 鍙戣〃璇勮
]]>
USACO 3.3 A Gamehttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.htmlYZYYZYThu, 09 Jul 2009 05:50:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.htmlhttp://www.shnenglu.com/yuziyu/comments/89638.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/09/89638.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89638.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89638.html鍔ㄦ佽鍒掓硶銆?br />鐢╠p[player][start][end]琛ㄧずplayer鍦╗start..end]浼氬彇寰楃殑鏈澶у箋?br />濡傛灉player==0錛岄偅涔坧layer鏈変富鍔ㄦ潈錛屽畠瑕佷箞閫塻tart,瑕佷箞閫塭nd.鏄劇劧錛屽畠瑕侀変嬌寰楀鎵嬪緱鍒嗘渶灝戠殑閭d竴涓?br />褰撳畠閫塻tart鏃訛紝瀵規(guī)墜鎵鑳藉埌鐨勬渶澶у間負dp[1][start+1][end]銆傚綋瀹冮塭nd鏃訛紝瀵規(guī)墜鎵閫夌殑鏈澶у兼槸dp[1][start][end-1].
銆傛墍浠ユ垜浠塪p[1][start+1][end]鍜宒p[1][start][end-1]涓皬鐨勯偅涓涓?br />濡傛灉player==1錛岄偅鍙兘琚姩鐨勭瓑0鍏堥変簡銆?鍦ㄥ墿涓嬪尯孌典腑錛屽張浣滀負鍏堥夌殑瑙掕壊錛屽嵆player0銆?br />褰撳彧鏈変竴涓暟瀛楃殑鏃跺欙紝player0灝卞彧鏈夐夎繖涓紝player1灝辨病寰楅夛紝榪斿洖0.
浠g爜濡備笅錛?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"game1.in");
ofstream聽fout(
"game1.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽dp[2][100][100];
int聽sequence[100];

int聽score(int聽player,int聽start,int聽end)
{
聽聽聽聽
if(dp[player][start][end]!=-1)
聽聽聽聽聽聽聽聽
return聽dp[player][start][end];

聽聽聽聽
if(start==end){
聽聽聽聽聽聽聽聽
if(player==0)
聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[start];
聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=0;
聽聽聽聽}
else{
聽聽聽聽聽聽聽聽
int聽t1聽=聽score(0,start+1,end);
聽聽聽聽聽聽聽聽
int聽t2聽=聽score(0,start,end-1);
聽聽聽聽聽聽聽聽
if(player==0){
聽聽聽聽聽聽聽聽聽聽聽聽
if(t1>t2){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[end]+score(1,start,end-1);
聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽sequence[start]+score(1,start+1,end);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽
if(t1>t2){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽score(0,start,end-1);
聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[player][start][end]聽
=聽score(0,start+1,end);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
return聽dp[player][start][end];
}

void聽solve()
{
聽聽聽聽memset(dp,
-1,sizeof(dp));

聽聽聽聽
int聽size;
聽聽聽聽
in>>size;

聽聽聽聽
for(int聽i=0;i<size;++i)
聽聽聽聽聽聽聽聽
in>>sequence[i];

聽聽聽聽
out<<score(0,0,size-1)<<""<<score(1,0,size-1)<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-09 13:50 鍙戣〃璇勮
]]>
USACO 3.3 Home on the Rangehttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.htmlYZYYZYWed, 08 Jul 2009 09:44:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.htmlhttp://www.shnenglu.com/yuziyu/comments/89557.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/08/89557.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89557.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89557.html濡傛灉dp[i][j][m]瀹屾暣錛屽垯褰撲笖浠呭綋dp[i][j][m-1],dp[i+1][j][m-1],dp[i][j+1][m-1],dp[i+1][j+1][m-1]鐨勬鏂瑰艦涔熸槸瀹屾暣鐨?鐢諱釜鍥懼氨寰堟竻鏅頒簡)銆傜敱浜庢垜浠粠涓婂埌涓嬶紝浠庡乏鍒板彸鎵弿姣忎釜鐐癸紝鍦ㄦ瘡涓杞甶,j鐢ㄨ繃涓嬈★紝灝變笉浼氬啀浣跨敤錛屾墍浠ュ彧闇鐢ㄤ簩緇存暟緇勪繚瀛榙p[i][j]錛屽嵆鍙?br />鏃墮棿澶嶆潅搴︿負O(n^3),絀洪棿澶嶆潅搴︿負O(n^2)銆俛nalysis涓湁涓椂闂村鏉傚害涓篛(n^2),絀洪棿O(n)鐨勮В娉曘?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"range.in");
ofstream聽fout(
"range.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

bool聽dp[250][250];
int聽side_len;

void聽input()
{
聽聽聽聽
in>>side_len;

聽聽聽聽
char聽t;

聽聽聽聽
for(int聽i=0;i<side_len;++i){
聽聽聽聽聽聽聽聽
for(int聽j=0;j<side_len;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
while(聽in.get(t)&&isspace(t)聽);
聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j]聽
=聽t-'0';
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽input();

聽聽聽聽
for(int聽w聽=2;w<=side_len;++w){
聽聽聽聽聽聽聽聽
int聽cnt聽=0;

聽聽聽聽聽聽聽聽
for(int聽i=0;i<side_len;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽j=0;j<side_len;++j){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i+w<=side_len&&j+w<=side_len){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽dp[i][j]聽
=聽dp[i][j]&&dp[i+1][j]&&dp[i][j+1]&&dp[i+1][j+1];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(dp[i][j])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cnt
++;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
if(cnt!=0){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<w<<""<<cnt<<endl;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-07-08 17:44 鍙戣〃璇勮
]]>
USACO 3.3 Riding The Fences http://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.htmlYZYYZYTue, 07 Jul 2009 08:59:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.htmlhttp://www.shnenglu.com/yuziyu/comments/89469.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/07/89469.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89469.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89469.html闃呰鍏ㄦ枃

YZY 2009-07-07 16:59 鍙戣〃璇勮
]]>
USACO 3.2 Sweet Butterhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.htmlYZYYZYMon, 06 Jul 2009 12:05:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.htmlhttp://www.shnenglu.com/yuziyu/comments/89393.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89393.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89393.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89393.html闃呰鍏ㄦ枃

YZY 2009-07-06 20:05 鍙戣〃璇勮
]]>
USACO 3.2 Magic Squareshttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.htmlYZYYZYMon, 06 Jul 2009 12:01:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.htmlhttp://www.shnenglu.com/yuziyu/comments/89392.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/06/89392.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89392.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89392.html
#include聽<iostream>
#include聽
<fstream>
#include聽
<set>
#include聽
<queue>

usingnamespace聽std;

ifstream聽fin(
"msquare.in");
ofstream聽fout(
"msquare.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽final[8];
set<int>visited;
char聽result[8*7*6*5*4*3*2*1+1];

struct聽queue_node{
聽聽聽聽
int聽current[8];
聽聽聽聽queue_node聽
*parent;
聽聽聽聽
char聽op;
};

void聽op(int*current,char聽c)
{
聽聽聽聽
int聽tmp;
聽聽聽聽
switch(c){
聽聽聽聽聽聽聽聽
case'A':
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=0;i<4;++i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽swap(current[i],current[
7-i]);
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case'B':
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[3];
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=3;i>=1;--i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽current[i]聽
=聽current[i-1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
0]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[4];
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=4;i<=6;++i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽current[i]聽
=聽current[i+1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
7]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case'C':
聽聽聽聽聽聽聽聽聽聽聽聽tmp聽
=聽current[6];
聽聽聽聽聽聽聽聽聽聽聽聽current[
6]聽=聽current[5];
聽聽聽聽聽聽聽聽聽聽聽聽current[
5]聽=聽current[2];
聽聽聽聽聽聽聽聽聽聽聽聽current[
2]聽=聽current[1];
聽聽聽聽聽聽聽聽聽聽聽聽current[
1]聽=聽tmp;
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽}
}

int聽cur_value(int*cur)
{
聽聽聽聽
int聽res聽=0;
聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽res
*=10;
聽聽聽聽聽聽聽聽res
+=cur[i];
聽聽聽聽}

聽聽聽聽
return聽res;
}


void聽solve()
{
聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽
in>>final[i];
聽聽聽聽}

聽聽聽聽queue
<queue_node*>聽q;
聽聽聽聽queue_node聽
*node聽=new聽queue_node;
聽聽聽聽
for(int聽i=0;i<8;++i)
聽聽聽聽聽聽聽聽node
->current[i]聽=聽i+1;

聽聽聽聽node
->parent聽=聽NULL;

聽聽聽聽q.push(node);

聽聽聽聽
while(聽!q.empty()聽){
聽聽聽聽聽聽聽聽queue_node聽
*node聽=聽q.front();
聽聽聽聽聽聽聽聽q.pop();

聽聽聽聽聽聽聽聽
int聽cur聽=聽cur_value(node->current);
聽聽聽聽聽聽聽聽
if(聽visited.find(聽cur)聽!=聽visited.end())
聽聽聽聽聽聽聽聽聽聽聽聽
continue;
聽聽聽聽聽聽聽聽visited.insert(cur);

聽聽聽聽聽聽聽聽
bool聽ok聽=true;
聽聽聽聽聽聽聽聽
for(int聽i=0;i<8;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
if(node->current[i]!=final[i]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽ok聽
=false;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
if(ok){
聽聽聽聽聽聽聽聽聽聽聽聽
int聽i聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
while(node->parent!=NULL){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽result[i
++]聽=聽node->op;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node
=node->parent;
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
if(i==0){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<0<<endl<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
out<<i<<endl;

聽聽聽聽聽聽聽聽聽聽聽聽
int聽j;
聽聽聽聽聽聽聽聽聽聽聽聽i
--;
聽聽聽聽聽聽聽聽聽聽聽聽
for(j=0;i>=0;i--,j++){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<result[i];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(j%60==59)聽out<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽
if(j%60!=0)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<endl;

聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
for(char聽c='A';c<='C';++c){
聽聽聽聽聽聽聽聽聽聽聽聽queue_node聽
*聽n聽=new聽queue_node;
聽聽聽聽聽聽聽聽聽聽聽聽memcpy(n
->current,node->current,sizeof(node->current));
聽聽聽聽聽聽聽聽聽聽聽聽op(n
->current,c);
聽聽聽聽聽聽聽聽聽聽聽聽n
->op聽=聽c;
聽聽聽聽聽聽聽聽聽聽聽聽n
->parent聽=聽node;
聽聽聽聽聽聽聽聽聽聽聽聽q.push(n);
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-07-06 20:01 鍙戣〃璇勮
]]>
USACO 3.2 Spinning Wheelshttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.htmlYZYYZYSat, 04 Jul 2009 12:49:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.htmlhttp://www.shnenglu.com/yuziyu/comments/89252.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/04/89252.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89252.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89252.html鐢ㄤ竴涓暟緇勮褰曡兘閫忚繃0-359鐨勮疆瀛愮殑涓暟錛屽綋鍦ㄦ煇涓搴﹁疆瀛愮殑涓暟杈懼埌浜?錛屽垯璇存槑鍏夊彲浠ラ忚繃錛岃緭鍑哄嵆鍙?br />鍚﹀垯璇存槑鏄笉鍙兘鏈夊厜閫忚繃銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream in(
"spin.in");
ofstream out(
"spin.out");

struct聽wedge{
聽聽聽聽
int聽start;
聽聽聽聽
int聽extent;
};

int聽speed[5];
wedge聽wedges[
5][5];
int聽wedge_num[5];

void聽onesecond()
{
聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽wedges[i][j].start
+=speed[i];
聽聽聽聽聽聽聽聽聽聽聽wedges[i][j].start
%=360;
聽聽聽聽聽聽聽}
聽聽聽}聽
}

bool聽isok()
{
聽聽聽聽
int聽tmp[360];

聽聽聽聽memset(tmp,
0,sizeof(tmp));

聽聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽k=0;k<=wedges[i][j].extent;++k)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽tmp[(wedges[i][j].start
+k)%360]++;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
for(int聽i=0;i<360;++i)
聽聽聽聽聽聽聽聽
if(tmp[i]==5)
聽聽聽聽聽聽聽聽聽聽聽聽
returntrue;

聽聽聽聽
returnfalse;
}

void聽solve()
{
聽聽聽聽
for(int聽i=0;i<5;++i){
聽聽聽聽聽聽聽聽
in>>speed[i];
聽聽聽聽聽聽聽聽
in>>wedge_num[i];
聽聽聽聽聽聽聽聽
for(int聽j=0;j<wedge_num[i];++j){
聽聽聽聽聽聽聽聽聽聽聽聽
in>>wedges[i][j].start>>wedges[i][j].extent;
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽
out<<0<<endl;
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}

聽聽聽聽
for(int聽i=1;i<=360;++i){
聽聽聽聽聽聽聽聽onesecond();
聽聽聽聽聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<i<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽
return;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
聽聽聽聽
out<<"none"<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}



YZY 2009-07-04 20:49 鍙戣〃璇勮
]]>
USACO 3.2 Stringsobitshttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89191.htmlYZYYZYFri, 03 Jul 2009 12:45:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89191.htmlhttp://www.shnenglu.com/yuziyu/comments/89191.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89191.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89191.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89191.html棣栧厛璁$畻鍑虹粍鍚堟暟銆傜敤cmb_num[i][j]琛ㄧずi浣嶆暟涓紝"1鐨勪綅鏁板皬浜庣瓑浜巎"鐨勬暟鐨勪釜鏁般?br />榪欐牱錛屾垜浠粠鏈宸﹁竟寮濮嬶紝濡傛灉cmb_num[i-1][j]鐨勬暟澶т簬n錛岃鏄庣涓浣嶄負0錛屽洜涓虹敤i-1浣嶆暟涓?1鐨勪綅鏁板皬浜庣瓑浜巎"鐨勬暟宸茬粡澶т簬n涓簡銆?br />濡傛灉灝忎簬n錛岃鏄庣涓浣嶄負1錛岄渶瑕乮浣嶏紝鎵嶈兘浣?1鐨勪綅鏁板皬浜庣瓑浜巎"鐨勬暟澶т簬n涓簡銆傛棦鐒剁涓浣嶅凡緇忔槸1浜嗭紝鎺ヤ笅鏉ョ殑i-1浣嶇粍鎴愮殑鏁扮殑1鐨勪釜鏁板彧鑳藉皬浜庣瓑浜巒-1浣嶄簡銆傝凱浠h緭鍑烘瘡涓浣嶅嵆鍙?br />鍙槸瑕佹敞鎰忔孩鍑虹殑闂浠ュ強cmb_num[0][1]銆?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"kimbits.in");
ofstream聽fout(
"kimbits.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

unsigned聽
int聽cmb_num[32][32];

void聽build_cmb_num()
{
聽聽聽聽
for(int聽i=0;i<32;++i)
聽聽聽聽聽聽聽聽cmb_num[i][
0]聽=1;

聽聽聽聽
for(int聽i=1;i<32;++i)
聽聽聽聽聽聽聽聽
for(int聽j=1;j<=i;++j)
聽聽聽聽聽聽聽聽聽聽聽聽cmb_num[i][j]聽
=聽cmb_num[i-1][j-1]+cmb_num[i-1][j];

聽聽聽聽
for(int聽i=0;i<32;++i)
聽聽聽聽聽聽聽聽
for(int聽j=1;j<32;++j){
聽聽聽聽聽聽聽聽聽聽聽聽cmb_num[i][j]
+=cmb_num[i][j-1];
聽聽聽聽聽聽聽聽}
}


void聽solve()
{
聽聽聽聽build_cmb_num();

聽聽聽聽unsigned聽聽n,l,i;
聽聽聽聽
in>>n>>l>>i;

聽聽聽聽
for(unsigned聽idx=n;idx>0;--idx){
聽聽聽聽聽聽聽聽
if(聽i>聽cmb_num[idx-1][l]聽){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<1;
聽聽聽聽聽聽聽聽聽聽聽聽i
-=cmb_num[idx-1][l];
聽聽聽聽聽聽聽聽聽聽聽聽l
--;
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽
out<<0;
聽聽聽聽聽聽聽聽}聽聽聽
聽聽聽聽}

聽聽聽聽
out<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}

闄勯錛?br />
Stringsobits
Kim Schrijvers

Consider an ordered set S of strings of N (1 <= N <= 31) bits. Bits, of course, are either 0 or 1.

This set of strings is interesting because it is ordered and contains all possible strings of length N that have L (1 <= L <= N) or fewer bits that are `1'.

Your task is to read a number I (1 <= I <= sizeof(S)) from the input and print the Ith element of the ordered set for N bits with no more than L bits that are `1'.

PROGRAM NAME: kimbits

INPUT FORMAT

A single line with three space separated integers: N, L, and I.

SAMPLE INPUT (file kimbits.in)

5 3 19

OUTPUT FORMAT

A single line containing the integer that represents the Ith element from the order set, as described.

SAMPLE OUTPUT (file kimbits.out)

10011



YZY 2009-07-03 20:45 鍙戣〃璇勮
]]>
USACO 3.2 Factorialshttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89186.htmlYZYYZYFri, 03 Jul 2009 11:52:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89186.htmlhttp://www.shnenglu.com/yuziyu/comments/89186.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/03/89186.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89186.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89186.html榪欓涓昏鏄幓鎺夐樁涔樻湯灝劇殑0銆傛槸涓侀浜嗭紝緙栫▼涔嬬編涓氨鏈夎璁恒傚洜涓?閮芥槸鐢?*5寰楁潵鐨勩傚彧瑕佹壘鍑轟箻鏁頒腑鏈夊灝戜釜2*5瀵瑰氨琛屼簡銆?br />鍥犱負2鐨勪釜鏁拌繙澶氫簬5錛屾墍浠ュ彧瑕佹壘鍑?鐨勪釜鏁板嵆鍙傚洜涓簄鏈澶т負4220,5鐨勪釜鏁頒負:
n/5+n/5/5+n/5/5/5+n/5/5/5/5+n/5/5/5/5/5+n/5/5/5/5/5/5;
鐒跺悗鍐嶅幓闄ょ浉搴旀暟鐩殑2銆傝繖鏍峰墿涓嬬殑鏁板彧闇涓や袱鐩鎬箻鍚庡彇鏈鍚庝竴浣嶅嵆鍙?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream in(
"fact4.in");
ofstream out(
"fact4.out");

void聽solve()
{
聽聽聽聽
int聽n;
聽聽聽聽
in>>n;

聽聽聽聽
int聽numof5聽=聽n/5+n/5/5+n/5/5/5+n/5/5/5/5+n/5/5/5/5/5+n/5/5/5/5/5/5;

聽聽聽聽
int聽res聽=1;

聽聽聽聽
int聽tmp;

聽聽聽聽
for(int聽i=1;i<=n;++i){
聽聽聽聽聽聽聽聽tmp聽
=聽i;
聽聽聽聽聽聽聽聽
while(tmp%5==0)聽tmp/=5;
聽聽聽聽聽聽聽聽
while(tmp%2==0&&numof5!=0){
聽聽聽聽聽聽聽聽聽聽聽聽tmp
/=2;
聽聽聽聽聽聽聽聽聽聽聽聽numof5
--;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽res
*=tmp;
聽聽聽聽聽聽聽聽res
%=10;
聽聽聽聽}

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}


鍘熼錛?br />
Factorials

The factorial of an integer N, written N!, is the product of all the integers from 1 through N inclusive. The factorial quickly becomes very large: 13! is too large to store in a 32-bit integer on most computers, and 70! is too large for most floating-point variables. Your task is to find the rightmost non-zero digit of n!. For example, 5! = 1 * 2 * 3 * 4 * 5 = 120, so the rightmost non-zero digit of 5! is 2. Likewise, 7! = 1 * 2 * 3 * 4 * 5 * 6 * 7 = 5040, so the rightmost non-zero digit of 7! is 4.

PROGRAM NAME: fact4

INPUT FORMAT

A single positive integer N no larger than 4,220.

SAMPLE INPUT (file fact4.in)

7

OUTPUT FORMAT

A single line containing but a single digit: the right most non-zero digit of N! .

SAMPLE OUTPUT (file fact4.out)

4



YZY 2009-07-03 19:52 鍙戣〃璇勮
]]>
USACO 3.1 Contacthttp://www.shnenglu.com/yuziyu/archive/2009/07/02/89112.htmlYZYYZYThu, 02 Jul 2009 14:07:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/07/02/89112.htmlhttp://www.shnenglu.com/yuziyu/comments/89112.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/07/02/89112.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/89112.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/89112.html瀛楃涓茬殑闀垮害鏈夐檺(鏈澶氬彧鏈?2浣?錛屾垜寤轟竴涓猼rie鏍戞潵瀛樺偍鎵鏈夊瓧絎︿覆錛岀劧鍚庨亶鍘唗rie鏍戯紝灝嗗搴旂殑瀛楃涓插瓨鍌ㄥ埌涓涓獀ector涓紝鍐嶆帓搴忚緭鍑恒?br />ac浠ュ悗錛岀湅usaco鐨勫垎鏋愶紝鏄敤浣嶄覆鏉ュ仛绱㈠紩璁℃暟錛岃繖縐嶆柟娉曟瘮杈冪畝媧佸閥濡欍備負浜嗚В鍐沖墠緙涓?鐨勯棶棰橈紝鍦ㄦ瘡涓瓧絎︿覆鍓嶉潰鍔犱簡涓涓?錛岃緭鍑虹殑鏃跺欏啀鍘繪帀銆?br />鎴戠殑瑙f硶濡備笅錛?br />
#include聽<iostream>
#include聽
<fstream>
#include聽
<vector>
#include聽
<string>

usingnamespace聽std;

ifstream聽fin(
"contact.in");
ofstream聽fout(
"contact.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

struct聽trie_node{
聽聽聽聽
int聽cnt;
聽聽聽聽trie_node
*聽sons[2];
聽聽聽聽trie_node(){
聽聽聽聽聽聽聽聽sons[
0]聽=聽sons[1]聽=0;
聽聽聽聽聽聽聽聽cnt聽
=0;
聽聽聽聽}
};

struct聽sort_node{
聽聽聽聽
string聽str;
聽聽聽聽
int聽cnt;

聽聽聽聽
booloperator<(const聽sort_node&n2)聽const{
聽聽聽聽聽聽聽聽
if(cnt!=n2.cnt)聽return聽cnt>n2.cnt;
聽聽聽聽聽聽聽聽
if(str.size()!=n2.str.size())聽return聽str.size()<n2.str.size();
聽聽聽聽聽聽聽聽
for(int聽i=0;i<str.size();++i){
聽聽聽聽聽聽聽聽聽聽聽聽
if(str[i]!=n2.str[i])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽str[i]<n2.str[i];
聽聽聽聽聽聽聽聽}
聽聽聽聽}
};

char聽buf[200000];
int聽buf_len;
int聽a,b,n;
vector
<sort_node>res;

void聽insert_trie(trie_node*root,constchar*start,int聽len)
{
聽聽聽聽trie_node聽
*聽next聽=聽root;

聽聽聽聽
for(int聽i=0;i<len;++i){
聽聽聽聽聽聽聽聽
if(next->sons[start[i]-'0']==NULL)
聽聽聽聽聽聽聽聽聽聽聽聽next
->sons[start[i]-'0']聽=new聽trie_node;
聽聽聽聽聽聽聽聽next聽
=聽next->sons[start[i]-'0'];
聽聽聽聽聽聽聽聽
if(i+1>=a&&i+1<=b)
聽聽聽聽聽聽聽聽聽聽聽聽next
->cnt++;
聽聽聽聽}
}

void聽_traverse_trie(trie_node聽*root,char聽ch,int聽depth)
{
聽聽聽聽
if(root==NULL)聽return;

聽聽聽聽buf[depth]
=ch;

聽聽聽聽
if(root->cnt!=0){
聽聽聽聽聽聽聽聽sort_node聽n;
聽聽聽聽聽聽聽聽n.str聽
=string(&buf[0],&buf[depth+1]);
聽聽聽聽聽聽聽聽n.cnt聽
=聽root->cnt;
聽聽聽聽聽聽聽聽res.push_back(n);
聽聽聽聽}

聽聽聽聽_traverse_trie(root
->sons[0],'0',depth+1);
聽聽聽聽_traverse_trie(root
->sons[1],'1',depth+1);
}

void聽traverse_trie(trie_node聽*root)
{
聽聽聽聽_traverse_trie(root
->sons[0],'0',0);
聽聽聽聽_traverse_trie(root
->sons[1],'1',0);
}


void聽solve()
{
聽聽聽聽
in>>a>>b>>n;

聽聽聽聽
char聽ch;
聽聽聽聽
while(in.get(ch)){
聽聽聽聽聽聽聽聽
if(ch=='0'||ch=='1')
聽聽聽聽聽聽聽聽聽聽聽聽buf[buf_len
++]聽=聽ch;
聽聽聽聽}

聽聽聽聽trie_node聽root;

聽聽聽聽
for(int聽i=0;i+b<=buf_len;++i){
聽聽聽聽聽聽聽聽insert_trie(
&root,&buf[i],b);
聽聽聽聽}

聽聽聽聽
for(int聽i=min(b-1,buf_len);i>=a;--i){
聽聽聽聽聽聽聽聽insert_trie(
&root,&buf[buf_len-i],i);
聽聽聽聽}

聽聽聽聽traverse_trie(
&root);

聽聽聽聽sort(res.begin(),res.end());

聽聽聽聽
int聽freq_cnt聽=0;
聽聽聽聽
int聽last_cnt聽=-1;
聽聽聽聽
int聽out_cnt聽=0;

聽聽聽聽
for(int聽i=0;i<res.size();++i){
聽聽聽聽聽聽聽聽
if(res[i].cnt==last_cnt){
聽聽聽聽聽聽聽聽聽聽聽聽
if(out_cnt%6!=0)
聽聽聽聽聽聽聽聽聽聽聽聽
out<<"";
聽聽聽聽聽聽聽聽聽聽聽聽
out<<res[i].str;
聽聽聽聽聽聽聽聽聽聽聽聽out_cnt
++;
聽聽聽聽聽聽聽聽聽聽聽聽
if(out_cnt%6==0||i==(res.size()-1)||res[i+1].cnt!=res[i].cnt)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<endl;
聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽last_cnt聽
=聽res[i].cnt;
聽聽聽聽聽聽聽聽聽聽聽聽freq_cnt
++;
聽聽聽聽聽聽聽聽聽聽聽聽
if(freq_cnt>n)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
break;聽
聽聽聽聽聽聽聽聽聽聽聽聽
out<<res[i].cnt<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽
out<<res[i].str;
聽聽聽聽聽聽聽聽聽聽聽聽out_cnt聽
=0;
聽聽聽聽聽聽聽聽聽聽聽聽out_cnt
++;
聽聽聽聽聽聽聽聽聽聽聽聽
if(聽(i==res.size()-1)||res[i+1].cnt!=res[i].cnt)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<endl;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}


闄勯錛?br />
Contact
IOI'98

The cows have developed a new interest in scanning the universe outside their farm with radiotelescopes. Recently, they noticed a very curious microwave pulsing emission sent right from the centre of the galaxy. They wish to know if the emission is transmitted by some extraterrestrial form of intelligent life or if it is nothing but the usual heartbeat of the stars.

Help the cows to find the Truth by providing a tool to analyze bit patterns in the files they record. They are seeking bit patterns of length A through B inclusive (1 <= A <= B <= 12) that repeat themselves most often in each day's data file. They are looking for the patterns that repeat themselves most often. An input limit tells how many of the most frequent patterns to output.

Pattern occurrences may overlap, and only patterns that occur at least once are taken into account.

PROGRAM NAME: contact

INPUT FORMAT

Line 1: Three space-separated integers: A, B, N; (1 <= N < 50)
Lines 2 and beyond: A sequence of as many as 200,000 characters, all 0 or 1; the characters are presented 80 per line, except potentially the last line.

SAMPLE INPUT (file contact.in)

2 4 10
01010010010001000111101100001010011001111000010010011110010000000

In this example, pattern 100 occurs 12 times, and pattern 1000 occurs 5 times. The most frequent pattern is 00, with 23 occurrences.

OUTPUT FORMAT

Lines that list the N highest frequencies (in descending order of frequency) along with the patterns that occur in those frequencies. Order those patterns by shortest-to-longest and increasing binary number for those of the same frequency. If fewer than N highest frequencies are available, print only those that are.

Print the frequency alone by itself on a line. Then print the actual patterns space separated, six to a line (unless fewer than six remain).

SAMPLE OUTPUT (file contact.out)

23
00
15
01 10
12
100
11
11 000 001
10
010
8
0100
7
0010 1001
6
111 0000
5
011 110 1000
4
0001 0011 1100



YZY 2009-07-02 22:07 鍙戣〃璇勮
]]>
USACO 3.1 Stampshttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88924.htmlYZYYZYTue, 30 Jun 2009 12:37:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88924.htmlhttp://www.shnenglu.com/yuziyu/comments/88924.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88924.html#Feedback8http://www.shnenglu.com/yuziyu/comments/commentRss/88924.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88924.html闃呰鍏ㄦ枃

YZY 2009-06-30 20:37 鍙戣〃璇勮
]]>
USACO 3.1 Humble Numbershttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88846.htmlYZYYZYMon, 29 Jun 2009 16:05:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88846.htmlhttp://www.shnenglu.com/yuziyu/comments/88846.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/30/88846.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88846.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88846.html闃呰鍏ㄦ枃

YZY 2009-06-30 00:05 鍙戣〃璇勮
]]>
USACO 3.1 Score Inflationhttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88840.htmlYZYYZYMon, 29 Jun 2009 14:21:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88840.htmlhttp://www.shnenglu.com/yuziyu/comments/88840.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88840.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88840.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88840.html闃呰鍏ㄦ枃

YZY 2009-06-29 22:21 鍙戣〃璇勮
]]>
USACO 3.1 Agri-Nethttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88836.htmlYZYYZYMon, 29 Jun 2009 13:48:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88836.htmlhttp://www.shnenglu.com/yuziyu/comments/88836.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/29/88836.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88836.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88836.html  闃呰鍏ㄦ枃

YZY 2009-06-29 21:48 鍙戣〃璇勮
]]>
USACO 2.4 Fractions to Decimalshttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88708.htmlYZYYZYSun, 28 Jun 2009 10:49:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88708.htmlhttp://www.shnenglu.com/yuziyu/comments/88708.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88708.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88708.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88708.html闃呰鍏ㄦ枃

YZY 2009-06-28 18:49 鍙戣〃璇勮
]]>
USACO 2.4 Bessie Come Homehttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88701.htmlYZYYZYSun, 28 Jun 2009 09:25:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88701.htmlhttp://www.shnenglu.com/yuziyu/comments/88701.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/28/88701.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88701.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88701.html闃呰鍏ㄦ枃

YZY 2009-06-28 17:25 鍙戣〃璇勮
]]>
USACO 2.4 Cow Tourshttp://www.shnenglu.com/yuziyu/archive/2009/06/27/88662.htmlYZYYZYSat, 27 Jun 2009 14:10:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/27/88662.htmlhttp://www.shnenglu.com/yuziyu/comments/88662.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/27/88662.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88662.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88662.html榪欓緇煎悎浜哾fs,floyd綆楁硶銆?br />
棣栧厛鐢?floyd璁$畻鍑轟袱涓や箣闂寸殑鏈鐭礬寰勩傜劧鍚庣敤dfs灝嗗浘鐫鑹層傚姣忎袱涓や笉鍚岄鑹茬殑緇撶偣錛屾垜浠妸瀹冧滑鐩歌繛錛岀劧鍚庣湅浜х敓鐨勫浘鐨勭洿寰勭殑澶у皬銆?br />鐩村緞鐨勫ぇ灝忓彧鍙兘浠嶄負鍘熶袱榪為氬浘鐩村緞涔嬩竴錛屾垨鑰呮槸鍖呮嫭鏂版坊鍔犵殑璺緞鎵浜х敓鐨勬渶闀胯礬寰勶紝鍙栬繖涓夎呬腑鐨勬渶澶у箋傛柊璺緞浜х敓鐨勬渶闀胯礬寰勫彧鍙兘鏄袱鐐圭殑璺濈鍔犱笂涓ょ偣鍒板叾浠栫偣鐨勬渶闀胯窛紱匯傛渶寮濮嬬殑鏃跺欏彧鑰冭檻浜嗘柊娣誨姞鐨勮礬寰勶紝娌¤冭檻鍘熺洿寰勪細姣旀柊璺緞澶х殑鎯呭喌錛寃a浜唍嬈°傘?br />
#include聽<iostream>
#include聽
<fstream>

#include聽
<cfloat>
#include聽
<cmath>

usingnamespace聽std;

ifstream聽fin(
"cowtour.in");
ofstream聽fout(
"cowtour.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

double聽path[150][150];

char聽graph[150][150];

int聽x[150];
int聽y[150];

int聽n;

int聽color[150];

double聽diameter[150];
double聽maxPath[150];

void聽floyd()
{
聽聽聽聽
for(int聽k=0;k<n;++k)
聽聽聽聽聽聽聽聽
for(int聽i=0;i<n;++i)
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽j=0;j<n;++j){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i!=j){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽path[i][j]
=min(path[i][j],path[i][k]+path[k][j]);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
}

void聽make_color(int聽i,int聽c)
{
聽聽聽聽
if(聽color[i]!=0聽)
聽聽聽聽聽聽聽聽
return;

聽聽聽聽color[i]聽
=聽c;

聽聽聽聽
for(int聽j=0;j<n;++j){
聽聽聽聽聽聽聽聽
if(color[j]==0&&graph[i][j])
聽聽聽聽聽聽聽聽聽聽聽聽make_color(j,c);
聽聽聽聽}
}


void聽solve()
{
聽聽聽聽
in>>n;

聽聽聽聽
for(int聽i=0;i<n;++i){
聽聽聽聽聽聽聽聽
in>>x[i]>>y[i];
聽聽聽聽}

聽聽聽聽
for(int聽i=0;i<n;++i){
聽聽聽聽聽聽聽聽
string聽s;
聽聽聽聽聽聽聽聽
in>>s;
聽聽聽聽聽聽聽聽
for(int聽j=0;j<n;++j){
聽聽聽聽聽聽聽聽聽聽聽聽graph[i][j]
=s[j]-'0';
聽聽聽聽聽聽聽聽聽聽聽聽
if(graph[i][j]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽path[i][j]聽
=聽sqrt(聽(x[i]-x[j])*(x[i]-x[j])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+(y[i]-y[j])*(y[i]-y[j])聽);
聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽path[i][j]聽
=聽DBL_MAX/4;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽floyd();

聽聽聽聽
int聽c聽=0;
聽聽聽聽
for(int聽i=0;i<n;++i)
聽聽聽聽聽聽聽聽
if(color[i]==0)
聽聽聽聽聽聽聽聽聽聽聽聽make_color(i,
++c);


聽聽聽聽
for(int聽i=0;i<n;++i){
聽聽聽聽聽聽聽聽maxPath[i]聽
=0;
聽聽聽聽聽聽聽聽
for(int聽j=0;j<n;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
if(i!=j&&color[i]==color[j]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽maxPath[i]聽
=聽max(maxPath[i],path[i][j]);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽diameter[color[i]]聽
=聽max(diameter[color[i]],maxPath[i]);
聽聽聽聽}


聽聽聽聽
double聽dia聽=聽DBL_MAX;

聽聽聽聽
for(int聽i=0;i<n;++i)
聽聽聽聽聽聽聽聽
for(int聽j=i+1;j<n;++j){

聽聽聽聽聽聽聽聽聽聽聽聽
if(color[i]==color[j])聽continue;

聽聽聽聽聽聽聽聽聽聽聽聽
double聽d1聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽p=0;p<n;++p){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i!=p&&color[i]==color[p])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽d1聽
=聽max(d1,path[i][p]);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
double聽d2聽=0;
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽p=0;p<n;++p){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(j!=p&&color[j]==color[p])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽d2聽
=聽max(d2,path[j][p]);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽
double聽dist聽=聽sqrt(聽(x[i]-x[j])*(x[i]-x[j])+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(y[i]
-y[j])*(y[i]-y[j])聽);

聽聽聽聽聽聽聽聽聽聽聽聽dia聽
=聽min(dia,max(d1+d2+dist,max(diameter[color[i]],diameter[color[j]]))聽);
聽聽聽聽聽聽聽聽}

聽聽聽聽
out.setf(ios::fixed,ios::floatfield);
聽聽聽聽
out.precision(6);
聽聽聽聽
out<<dia<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-06-27 22:10 鍙戣〃璇勮
]]>
USACO 2.4 Overfencinghttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88607.htmlYZYYZYFri, 26 Jun 2009 14:25:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88607.htmlhttp://www.shnenglu.com/yuziyu/comments/88607.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88607.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88607.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88607.html鎵懼嚭涓や釜榪峰鐨勫嚭鍙o紝鐒跺悗鍒嗗埆榪涜dfs錛屾眰鍑哄埌姣忎竴涓偣鐨勬渶鐭窛紱匯?br />鐒跺悗瀵規(guī)瘡涓涓偣錛屾眰鍒版渶鐭殑閭d釜鍑哄彛鐨勮窛紱伙紝鐒跺悗鍐嶆眰榪欎釜鍊肩殑鏈澶у煎嵆鍙?br />鎵懼嚭鍙e啓寰楁瘮杈冪箒鐞愩?br />
#include聽<iostream>
#include聽
<fstream>
#include聽
<queue>

usingnamespace聽std;

ifstream聽fin(
"maze1.in");
ofstream聽fout(
"maze1.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

char聽maze[2*100+1][2*38+1];

bool聽visited[100][38];

int聽shortest1[100][38];
int聽shortest2[100][38];

bool聽get_first;
int聽exit1r,exit1c;
int聽exit2r,exit2c;
int聽w,h;

struct聽queue_node{
聽聽聽聽
int聽i,j,depth;
聽聽聽聽queue_node(
int聽i,int聽j,int聽depth){
聽聽聽聽聽聽聽聽
this->i聽=聽i;
聽聽聽聽聽聽聽聽
this->j聽=聽j;
聽聽聽聽聽聽聽聽
this->depth聽=聽depth;
聽聽聽聽}
};

void聽bfs(int聽i,int聽j,int聽shortest[100][38])
{
聽聽聽聽queue
<queue_node>q;

聽聽聽聽q.push(queue_node(i,j,
1));

聽聽聽聽
while(!q.empty()){

聽聽聽聽聽聽聽聽queue_node聽node聽
=聽q.front();
聽聽聽聽聽聽聽聽q.pop();

聽聽聽聽聽聽聽聽
if(visited[node.i][node.j])
聽聽聽聽聽聽聽聽聽聽聽聽
continue;

聽聽聽聽聽聽聽聽visited[node.i][node.j]聽
=true;

聽聽聽聽聽聽聽聽shortest[node.i][node.j]聽
=聽node.depth;

聽聽聽聽聽聽聽聽
if(node.i!=0&&maze[2*node.i][2*node.j+1]==''){
聽聽聽聽聽聽聽聽聽聽聽聽q.push(queue_node(node.i
-1,node.j,node.depth+1));
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
if(node.i!=h-1&&maze[2*node.i+2][2*node.j+1]==''){
聽聽聽聽聽聽聽聽聽聽聽聽q.push(queue_node(node.i
+1,node.j,node.depth+1));
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
if(node.j!=0&&maze[2*node.i+1][2*node.j]==''){
聽聽聽聽聽聽聽聽聽聽聽聽q.push(queue_node(node.i,node.j
-1,node.depth+1));
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
if(node.j!=w-1&&maze[2*node.i+1][2*node.j+2]==''){
聽聽聽聽聽聽聽聽聽聽聽聽q.push(queue_node(node.i,node.j
+1,node.depth+1));
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽
in>>w>>h;

聽聽聽聽
for(int聽i=0;i<2*h+1;++i)
聽聽聽聽聽聽聽聽
for(int聽j=0;j<2*w+1;++j){

聽聽聽聽聽聽聽聽聽聽聽聽
do{
聽聽聽聽聽聽聽聽聽聽聽聽
in.get(maze[i][j]);
聽聽聽聽聽聽聽聽聽聽聽聽}
while(maze[i][j]=='\n');

聽聽聽聽聽聽聽聽聽聽聽聽
if((i==0||i==2*h||j==0||j==2*w)&&maze[i][j]==''){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(!get_first){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i==2*h)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit1r聽
=聽h-1;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit1r聽
=聽i/2;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(j==2*w)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit1c聽
=聽w-1;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit1c聽
=聽j/2;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽get_first聽
=true;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
else{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i==2*h)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit2r聽
=聽h-1;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit2r聽
=聽i/2;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(j==2*w)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit2c聽
=聽w-1;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
else
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit2c聽
=聽j/2;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}

聽聽聽聽memset(visited,
0,sizeof(visited));
聽聽聽聽bfs(exit1r,exit1c,shortest1);
聽聽聽聽memset(visited,
0,sizeof(visited));
聽聽聽聽bfs(exit2r,exit2c,shortest2);

聽聽聽聽
int聽res聽=聽INT_MIN;

聽聽聽聽
for(int聽i=0;i<h;++i)
聽聽聽聽聽
for(int聽j=0;j<w;++j){
聽聽聽聽聽聽聽聽聽res聽
=聽max(res,聽min(shortest1[i][j],shortest2[i][j])聽);
聽聽聽聽聽}

聽聽聽聽
out<<res<<endl;
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-06-26 22:25 鍙戣〃璇勮
]]>
USACO 2.4 The Tamworth Twohttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88597.htmlYZYYZYFri, 26 Jun 2009 12:48:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88597.htmlhttp://www.shnenglu.com/yuziyu/comments/88597.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88597.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88597.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88597.html妯℃嫙棰樸傛寜棰樼洰瑕佹眰緙栫爜鍗沖彲錛屾瘡榪囦竴鍒嗛挓錛屾洿鏂頒竴涓嬪啘澶拰濂剁墰鐨勭姸鎬併傚鏋滆鐘舵佷互鍓嶅嚭鐜拌繃錛岃鏄庢湁寰幆錛屼笉鍙兘鍒拌揪錛岃緭鍑?.

#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"ttwo.in");
ofstream聽fout(
"ttwo.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

char聽grid[10][10];

bool聽visited[10][10][4][10][10][4];

int聽north聽=0;
int聽east聽=1;
int聽south聽=2;
int聽west聽=3;

//鏂瑰悜涓?,1,2,3鏃跺悜鍓嶈蛋涓姝ow鍜宑olumn鐨勫鍔犲?/span>
int聽delr[4]聽=聽{
聽聽聽聽
-1,0,1,0
};
int聽delc[4]聽=聽{
聽聽聽聽
0,1,0,-1
};

//聽farmer鐨勫綋鍓峳ow,column,direction.
int聽fc,fr,fd;
int聽cc,cr,cd;

bool聽available(int聽i,int聽j)
{
聽聽聽聽
if(i>=0&&i<=9&&j>=0&&j<=9&&grid[i][j]!='*')
聽聽聽聽聽聽聽聽
returntrue;
聽聽聽聽
else
聽聽聽聽聽聽聽聽
returnfalse;
}

void聽one_step()
{
聽聽聽聽
if(聽available(聽fr+delr[fd],fc+delc[fd]聽)聽){
聽聽聽聽聽聽聽聽fr聽
+=聽delr[fd];
聽聽聽聽聽聽聽聽fc聽
+=聽delc[fd];
聽聽聽聽}
else{
聽聽聽聽聽聽聽聽fd
+=1;
聽聽聽聽聽聽聽聽fd
%=4;
聽聽聽聽}

聽聽聽聽
if(聽available(聽cr+delr[cd],cc+delc[cd]聽)聽){
聽聽聽聽聽聽聽聽cr聽
+=聽delr[cd];
聽聽聽聽聽聽聽聽cc聽
+=聽delc[cd];
聽聽聽聽}
else{
聽聽聽聽聽聽聽聽cd
+=1;
聽聽聽聽聽聽聽聽cd
%=4;
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽
for(int聽i=0;i<10;++i)
聽聽聽聽聽聽聽聽
for(int聽j=0;j<10;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
in>>grid[i][j];
聽聽聽聽聽聽聽聽聽聽聽聽
if(grid[i][j]=='F')
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽fr
=i,fc=j,fd=0;
聽聽聽聽聽聽聽聽聽聽聽聽
if(grid[i][j]=='C')
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cr
=i,cc=j,cd=0;
聽聽聽聽聽聽聽聽}

聽聽聽聽memset(visited,
0,sizeof(visited));

聽聽聽聽visited[fc][fr][fd][cc][cr][cd]聽
=true;

聽聽聽聽
int聽res聽=0;

聽聽聽聽
while(true){

聽聽聽聽聽聽聽聽one_step();
聽聽聽聽聽聽聽聽res
++;

聽聽聽聽聽聽聽聽
if(聽fc==cc&&fr==cr聽){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<res<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
if(visited[fc][fr][fd][cc][cr][cd]){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<0<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽visited[fc][fr][fd][cc][cr][cd]
=true;
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}




YZY 2009-06-26 20:48 鍙戣〃璇勮
]]>
USACO 2.3 Controlling Companieshttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88596.htmlYZYYZYFri, 26 Jun 2009 12:01:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88596.htmlhttp://www.shnenglu.com/yuziyu/comments/88596.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/26/88596.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88596.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88596.html


#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"concom.in");
ofstream聽fout(
"concom.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽stock[101][101];
int聽n;
bool聽control[101];

void聽add_control(int聽cr,int聽ce)
{
聽聽聽聽
if(control[ce])聽return;

聽聽聽聽control[ce]聽
=true;
聽聽聽聽
for(int聽i聽=1;聽i<=100;聽++i){
聽聽聽聽聽聽聽聽
if(i!=cr&&!control[i]){
聽聽聽聽聽聽聽聽聽聽聽聽stock[cr][i]
+=stock[ce][i];

聽聽聽聽聽聽聽聽聽聽聽聽
if(stock[cr][i]>50)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽add_control(cr,i);
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽memset(stock,
0,sizeof(stock));
聽聽聽聽
聽聽聽聽
in>>n;

聽聽聽聽
int聽i,j,p;

聽聽聽聽
while(n--){
聽聽聽聽聽聽聽聽
in>>i>>j>>p;
聽聽聽聽聽聽聽聽stock[i][j]聽
=聽p;
聽聽聽聽}
聽聽聽聽

聽聽聽
for(int聽i=1;i<=100;++i){

聽聽聽聽聽聽聽memset(control,
0,sizeof(control));

聽聽聽聽聽聽聽
for(int聽j=1;j<=100;++j){

聽聽聽聽聽聽聽聽聽聽聽
if(i==j)聽continue;

聽聽聽聽聽聽聽聽聽聽聽
if(聽stock[i][j]>50){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽add_control(i,j);
聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽
for(int聽j=1;j<=100;++j){
聽聽聽聽聽聽聽聽聽聽聽
if(control[j]){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<i<<''<<j<<endl;
聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽}
聽聽聽}聽
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}





YZY 2009-06-26 20:01 鍙戣〃璇勮
]]>
USACO 2.3 Money Systemshttp://www.shnenglu.com/yuziyu/archive/2009/06/25/88530.htmlYZYYZYThu, 25 Jun 2009 14:16:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/25/88530.htmlhttp://www.shnenglu.com/yuziyu/comments/88530.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/25/88530.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88530.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88530.html闃呰鍏ㄦ枃

YZY 2009-06-25 22:16 鍙戣〃璇勮
]]>
USACO 2.3 Zero Sumhttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88457.htmlYZYYZYWed, 24 Jun 2009 13:35:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88457.htmlhttp://www.shnenglu.com/yuziyu/comments/88457.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88457.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88457.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88457.html闃呰鍏ㄦ枃

YZY 2009-06-24 21:35 鍙戣〃璇勮
]]>
USACO 2.3 Cow Pedigreeshttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88453.htmlYZYYZYWed, 24 Jun 2009 12:55:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88453.htmlhttp://www.shnenglu.com/yuziyu/comments/88453.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/24/88453.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88453.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88453.html闃呰鍏ㄦ枃

YZY 2009-06-24 20:55 鍙戣〃璇勮
]]>
USACO 2.3 Longest Prefixhttp://www.shnenglu.com/yuziyu/archive/2009/06/23/88394.htmlYZYYZYTue, 23 Jun 2009 13:13:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/23/88394.htmlhttp://www.shnenglu.com/yuziyu/comments/88394.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/23/88394.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88394.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88394.html闃呰鍏ㄦ枃

YZY 2009-06-23 21:13 鍙戣〃璇勮
]]>
USACO 2.2 Runaround Numbershttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88197.htmlYZYYZYSat, 20 Jun 2009 14:35:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88197.htmlhttp://www.shnenglu.com/yuziyu/comments/88197.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88197.html#Feedback2http://www.shnenglu.com/yuziyu/comments/commentRss/88197.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88197.html鐢熸垚鎵鏈夐暱搴﹀皬浜?鐨勬帓鍒楁暟錛岀劧鍚庡垽鏂槸鍚︿負runaround鏁頒笖澶т簬m錛岃緭鍑虹涓涓ぇ浜巑鐨勭洿鎺xit鍗沖彲銆?br />鍥犱負9! = 362880錛屾暟鎹緝?yōu)畯锛屼笉浼毉憛鏃躲?br />
#include聽<iostream>
#include聽
<fstream>

usingnamespace聽std;

ifstream聽fin(
"runround.in");
ofstream聽fout(
"runround.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif

int聽m;
bool聽mark[10];
int聽figures[10];


void聽solve();
void聽permutation(int聽max_dep);
unsigned聽
long聽get_value(int聽len);
bool聽isok(int聽len);

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}

void聽solve()
{
聽聽聽聽
in>>m;

聽聽聽聽
int聽start聽=0;
聽聽聽聽
int聽tmp聽=聽m;
聽聽聽聽
while(tmp){
聽聽聽聽聽聽聽聽tmp
/=10;
聽聽聽聽聽聽聽聽start
++;
聽聽聽聽}

聽聽聽聽
for(int聽i=start;i<=9;++i){
聽聽聽聽聽聽聽聽permutation(i);
聽聽聽聽}
}


void聽_permutation(int聽depth,int聽max_dep)
{
聽聽聽聽
if(depth==max_dep){
聽聽聽聽聽聽
if(isok(max_dep)){
/*聽聽聽聽聽聽聽聽for(int聽i=0;i<max_dep;++i)
聽聽聽聽聽聽聽聽聽聽聽聽cout<<figures[i]<<'聽';
聽聽聽聽聽聽聽聽cout<<endl;
聽聽
*/聽聽聽聽聽聽聽unsigned聽long聽t聽=聽get_value(max_dep);

聽聽聽聽聽聽聽聽聽聽聽聽
if(t>m){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
out<<t<<endl;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽exit(
0);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
return;
聽聽聽聽}

聽聽聽聽
for(int聽i=1;i<=9;++i){
聽聽聽聽聽聽聽聽
if(!mark[i]){
聽聽聽聽聽聽聽聽聽聽聽聽mark[i]聽
=true;
聽聽聽聽聽聽聽聽聽聽聽聽figures[depth]聽
=聽i;
聽聽聽聽聽聽聽聽聽聽聽聽_permutation(depth
+1,max_dep);
聽聽聽聽聽聽聽聽聽聽聽聽mark[i]聽
=false;
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

//鐢熸垚闀垮害涓簂en鐨勫叏鎺掑垪
void聽permutation(int聽len)
{
聽聽聽聽memset(mark,
0,sizeof(mark));
聽聽聽聽_permutation(
0,len);
}

//鏄痳unaround鏁?/span>
bool聽isok(int聽len)
{
聽聽聽聽
int聽unvisited聽=聽len;
聽聽聽聽
bool聽mark[10];
聽聽聽聽memset(mark,
0,sizeof(mark));

聽聽聽聽
int聽i聽=0;
聽聽聽聽
while(unvisited--){
聽聽聽聽聽聽聽i
+=figures[i];聽i%=(len);
聽聽聽聽聽聽聽
if(mark[i])聽returnfalse;
聽聽聽聽聽聽聽mark[i]聽
=true;
聽聽聽聽}
聽聽聽聽
returntrue;
}

//灝嗘暟緇勮漿鍖栨垚unsigned聽long
unsigned聽long聽get_value(int聽len)
{
聽聽聽聽unsigned聽
long聽res聽=0;
聽聽聽聽
for(int聽i=0;i<len;++i){
聽聽聽聽聽聽聽聽res
*=10;
聽聽聽聽聽聽聽聽res
+=figures[i];
聽聽聽聽}

聽聽聽聽
return聽res;
}





YZY 2009-06-20 22:35 鍙戣〃璇勮
]]>
USACO 2.2 Party Lampshttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88188.htmlYZYYZYSat, 20 Jun 2009 12:33:00 GMThttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88188.htmlhttp://www.shnenglu.com/yuziyu/comments/88188.htmlhttp://www.shnenglu.com/yuziyu/archive/2009/06/20/88188.html#Feedback0http://www.shnenglu.com/yuziyu/comments/commentRss/88188.htmlhttp://www.shnenglu.com/yuziyu/services/trackbacks/88188.html鍏抽敭鍦ㄤ簬鍙戠幇鍑犱釜瑙勫緥錛?br />鏌愪竴鎸夐挳錛屾寜鍋舵暟嬈$瓑鍚屼簬娌℃寜銆?br />鎸夐挳鐨勫厛鍚庢搴忎笉褰卞搷緇撴灉銆?br />鐏殑鐘舵?浣嶄竴緇勪笉鍙?瑙i鏃舵病鍙戠幇榪欎釜瑙勫緥錛屽紑浜嗕釜100澶у皬鐨刡ool鏁扮粍)

鍓╀笅灝辨槸鍑犱釜鎿嶄綔鐨勬帓鍒楃粍鍚堜簡銆備唬鐮佸啓寰楀緢綣?..

#include聽<iostream>
#include聽
<fstream>
#include聽
<vector>
#include聽
<algorithm>

usingnamespace聽std;

ifstream聽fin(
"lamps.in");
ofstream聽fout(
"lamps.out");

#ifdef聽_DEBUG
#define聽out聽cout
#define聽in聽cin
#else
#define聽out聽fout
#define聽in聽fin
#endif


struct聽state_node{
聽聽聽聽
bool聽states[101];
聽聽聽聽
int聽len;
聽聽聽聽
booloperator<(const聽state_node聽&聽n1)聽const{
聽聽聽聽聽聽聽聽
for(int聽i=1;i<=len;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
if(states[i]!=n1.states[i])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
return聽states[i]<n1.states[i];
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽}
聽聽聽聽
booloperator==(const聽state_node聽&聽n1)聽const{
聽聽聽聽聽聽聽聽
for(int聽i=1;i<=len;++i){
聽聽聽聽聽聽聽聽聽聽聽聽
if(states[i]!=n1.states[i])
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
returntrue;
聽聽聽聽}
};

state_node聽node;

int聽n,c;
vector
<int>finalon,finaloff;

vector
<state_node>聽result;

void聽op(int聽kind)
{
聽聽聽聽
switch(kind){
聽聽聽聽聽聽聽聽
case1:
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=1;i<=n;++i)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node.states[i]
=!node.states[i];
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case2:
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=1;i<=n;++i){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i&1)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node.states[i]
=!node.states[i];
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case3:
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=1;i<=n;++i){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(!(i&1))
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node.states[i]
=!node.states[i];
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case4:
聽聽聽聽聽聽聽聽聽聽聽聽
for(int聽i=1;i<=n;++i){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
if(i%3==1){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽node.states[i]
=!node.states[i];
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽}
}

bool聽isok()
{
聽聽聽聽
for(int聽i=0;i<finalon.size();++i){
聽聽聽聽聽聽聽聽
if(!node.states[finalon[i]])
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽}
聽聽聽聽
for(int聽i=0;i<finaloff.size();++i){
聽聽聽聽聽聽聽聽
if(node.states[finaloff[i]])
聽聽聽聽聽聽聽聽聽聽聽聽
returnfalse;
聽聽聽聽}
聽聽聽聽
returntrue;
}

void聽do0()
{
聽聽聽聽
if(isok())
聽聽聽聽聽聽聽聽result.push_back(node);
}

void聽do1()
{
聽聽聽聽
for(int聽i=1;i<=4;++i){
聽聽聽聽聽聽聽聽op(i);
聽聽聽聽聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽聽聽聽聽result.push_back(node);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽op(i);
聽聽聽聽}
}

void聽do2()
{
聽聽聽聽
for(int聽i=1;i<=3;++i){
聽聽聽聽聽聽聽聽
for(int聽j=i+1;j<=4;++j){
聽聽聽聽聽聽聽聽聽聽聽聽op(i);
聽聽聽聽聽聽聽聽聽聽聽聽op(j);
聽聽聽聽聽聽聽聽聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽result.push_back(node);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽op(i);
聽聽聽聽聽聽聽聽聽聽聽聽op(j);

聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

void聽do3()
{
聽聽聽聽
//鎿嶄綔1,2,3,4鍚勬墽琛屼竴嬈★紝鍓嶄笁涓搷浣滄姷娑?/span>
聽聽聽聽op(4);
聽聽聽聽do1();
}

void聽do4()
{
聽聽聽聽op(
4);
聽聽聽聽
if(isok()){
聽聽聽聽聽聽聽聽result.push_back(node);
聽聽聽聽}
聽聽聽聽op(
4);
}

void聽action(int聽i)
{
聽聽聽聽
switch(i){
聽聽聽聽聽聽聽聽
case0:聽do0();break;
聽聽聽聽聽聽聽聽
case1:聽do1();break;
聽聽聽聽聽聽聽聽
case2:聽do2();break;
聽聽聽聽聽聽聽聽
case3:聽do3();break;
聽聽聽聽聽聽聽聽
case4:聽do4();break;
聽聽聽聽}
}

void聽solve()
{
聽聽聽聽
in>>n>>c;

聽聽聽聽node.len聽
=聽n;

聽聽聽聽
for(int聽i=1;i<=n;++i)聽
聽聽聽聽聽聽聽聽node.states[i]聽
=true;

聽聽聽聽
int聽t;
聽聽聽聽
do{
聽聽聽聽聽聽聽聽
in>>t;
聽聽聽聽聽聽聽聽
if(t!=-1)
聽聽聽聽聽聽聽聽聽聽聽聽finalon.push_back(t);
聽聽聽聽}
while(t!=-1);

聽聽聽聽聽
do{
聽聽聽聽聽聽聽聽
in>>t;
聽聽聽聽聽聽聽聽
if(t!=-1)
聽聽聽聽聽聽聽聽聽聽聽聽finaloff.push_back(t);
聽聽聽聽}
while(t!=-1);

聽聽聽聽
bool聽has_result聽=false;

聽聽聽聽
for(int聽i=0;i<=4;++i){
聽聽聽聽聽聽聽聽
if(c>=i&&(c-i)%2==0){
聽聽聽聽聽聽聽聽聽聽聽聽action(i);
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽sort(result.begin(),result.end());
聽聽聽聽vector
<state_node>::iterator聽end聽=
聽聽聽聽聽聽聽聽unique(result.begin(),result.end());

聽聽聽聽
for(vector<state_node>::iterator聽i聽=聽result.begin();
聽聽聽聽聽聽聽聽聽聽聽聽i
!=end;聽++i){
聽聽聽聽聽聽聽聽has_result聽
=true;
聽聽聽聽聽聽聽聽
for(int聽j=1;j<=n;++j){
聽聽聽聽聽聽聽聽聽聽聽聽
out<<i->states[j];
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
out<<endl;
聽聽聽聽}

聽聽聽聽
if(!has_result){
聽聽聽聽聽聽聽聽
out<<"IMPOSSIBLE"<<endl;
聽聽聽聽}
}

int聽main(int聽argc,char*argv[])
{
聽聽聽聽solve();聽
聽聽聽聽
return0;
}






YZY 2009-06-20 20:33 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲国产精品久久久| 午夜精彩国产免费不卡不顿大片| 亚洲视频免费在线| 久久疯狂做爰流白浆xx| 欧美国产日本在线| 亚洲香蕉伊综合在人在线视看| 久久激情五月激情| 欧美精品v国产精品v日韩精品| 国产精品―色哟哟| 亚洲欧洲一区二区在线观看| 亚洲性图久久| 免费一区视频| 亚洲午夜在线| 欧美xxx在线观看| 国产啪精品视频| 亚洲人体大胆视频| 久久精品论坛| 99国产精品自拍| 久久婷婷国产综合精品青草| 国产精品黄视频| 亚洲精品综合在线| 久久嫩草精品久久久精品一| 亚洲美女在线观看| 久久久综合免费视频| 国产精品久久久久久久浪潮网站 | 国产精品专区一| 亚洲精品免费电影| 久久天堂精品| 亚洲一二三区在线观看| 欧美精品videossex性护士| 国内外成人免费视频| 亚洲免费人成在线视频观看| 亚洲第一在线综合在线| 欧美与黑人午夜性猛交久久久| 亚洲美女视频在线观看| 亚洲国产精品一区二区久| 亚洲一级在线观看| 久久久久久高潮国产精品视| 欧美日韩中国免费专区在线看| 韩日欧美一区| 午夜精品久久一牛影视| 亚洲国产视频一区| 久久精品99久久香蕉国产色戒| 欧美揉bbbbb揉bbbbb| 亚洲第一主播视频| 久久av在线| 99re6这里只有精品视频在线观看| 久久精品九九| 国产麻豆成人精品| 在线视频日韩| 欧美激情成人在线| 亚洲一区二区三区欧美| 欧美sm视频| 尤物yw午夜国产精品视频明星| 性久久久久久| 99精品视频一区| 麻豆成人在线观看| 狠狠综合久久| 久久福利一区| 中日韩美女免费视频网站在线观看| 欧美/亚洲一区| 在线观看欧美日韩| 久久久在线视频| 午夜精品视频一区| 国产精品萝li| 一区二区激情| 日韩视频―中文字幕| 欧美激情第3页| 亚洲黄色影院| 欧美国产亚洲视频| 久久久久在线| 伊人久久婷婷| 久久亚洲不卡| 久久成年人视频| 国产在线观看91精品一区| 欧美在线观看一区| 亚洲欧美日韩精品一区二区| 国产精品v欧美精品v日韩 | 亚洲午夜久久久久久久久电影网| 亚洲电影欧美电影有声小说| 久久久精品日韩欧美| 狠狠干狠狠久久| 久久久久国产一区二区三区| 久久国产精品72免费观看| 国产主播精品| 久久一本综合频道| 久久婷婷激情| 亚洲第一毛片| 亚洲国产成人在线| 欧美伦理在线观看| 亚洲视频在线观看视频| 在线亚洲欧美视频| 欧美日韩免费高清一区色橹橹| 亚洲一区二区三区视频| 亚洲一区二区三区欧美| 国产欧美一区二区精品秋霞影院| 久久av一区二区三区亚洲| 欧美一级成年大片在线观看| 国产中文一区二区| 欧美wwwwww| 欧美国产综合视频| 亚洲私人影吧| 亚洲欧美日韩另类| 狠狠色狠狠色综合日日91app| 免费成人高清| 欧美刺激性大交免费视频| 亚洲精品社区| 99在线精品观看| 国产欧美日韩免费| 免费欧美日韩| 欧美日本韩国一区| 先锋资源久久| 久久夜色撩人精品| 一本久久综合亚洲鲁鲁| 亚洲自拍16p| 亚洲成人在线| 日韩视频亚洲视频| 国产精品自拍在线| 久久字幕精品一区| 欧美精品97| 欧美在线亚洲在线| 欧美成人a∨高清免费观看| 亚洲午夜久久久| 久久精品国产999大香线蕉| 亚洲国产专区校园欧美| 日韩一级成人av| 国产一区二区欧美| 亚洲激情成人网| 国产欧美日韩在线视频| 牛夜精品久久久久久久99黑人| 欧美国产日韩a欧美在线观看| 亚洲欧美日韩综合一区| 久久日韩精品| 亚洲一区在线看| 久久久综合精品| 午夜电影亚洲| 免费久久久一本精品久久区| 亚洲综合社区| 欧美jizzhd精品欧美巨大免费| 亚洲欧美在线磁力| 久久精品国产免费看久久精品| 亚洲无毛电影| 麻豆精品精品国产自在97香蕉| 亚洲欧美在线视频观看| 免费精品视频| 久久久久久久久久久一区| 免费观看久久久4p| 亚洲视频欧美视频| 久久综合狠狠| 久久国产天堂福利天堂| 欧美片网站免费| 蜜桃伊人久久| 国产精品一区二区三区乱码| 亚洲韩国青草视频| 精品51国产黑色丝袜高跟鞋| 中国av一区| 亚洲精品在线观| 久久精品夜色噜噜亚洲a∨| 亚洲一区二区三区乱码aⅴ| 免费国产自线拍一欧美视频| 久久精品日韩欧美| 国产精品乱码妇女bbbb| 亚洲精品国产精品国产自| 在线欧美影院| 久久国产高清| 久久国产欧美日韩精品| 欧美午夜精品久久久| 亚洲免费观看在线观看| 亚洲激情一区| 久久久久久久综合色一本| 久久福利毛片| 国产日韩欧美麻豆| 亚洲午夜在线视频| 亚洲性视频网址| 欧美日韩国产123| 牛牛精品成人免费视频| 国产一区二区三区高清| 亚洲欧美另类综合偷拍| 亚洲欧美日韩久久精品| 欧美视频一二三区| 亚洲精选成人| 一区二区激情| 欧美日韩高清区| 亚洲精品综合精品自拍| 亚洲第一精品久久忘忧草社区| 久久亚洲欧美国产精品乐播| 久久婷婷国产综合尤物精品| 国产日韩精品视频一区二区三区| 亚洲天堂成人| 午夜精品电影| 国产毛片精品视频| 亚洲欧美一区二区精品久久久| 小黄鸭精品aⅴ导航网站入口| 国产精品久久久久久久久久直播 | 免费亚洲一区| 欧美/亚洲一区| 亚洲国产三级| 免费一区视频| 亚洲精品一区二区在线观看| 一区二区三区欧美|