链接:https://www.nowcoder.com/acm/contest/118/A
来源:牛客网
PUBG
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
最近,喜爱ACM的PBY同学沉迷吃鸡,无法自拔,于是又来到了熟悉的ERANGEL。经过一番搜寻,PBY同学准备动身前往安全区,但是,地图中埋伏了许多LYB,PBY的枪法很差,希望你能够帮他找到一条路线,每次只能向上、下、左、右移动,尽可能遇到较少的敌人。
输入描述:
题目包含多组测试,请处理到文件结束;
第一行是一个整数n,代表地图的大小;
接下来的n行中,每行包含n个整数a,每个数字a代表当前位置敌人的数量;
1 < n <= 100,1 <= a <= 100,-1代表当前位置,-2代表安全区。
输出描述:
对于每组测试数据,请输出从当前位置到安全区所遇到最少的敌人数量,每个输出占一行。
示例1
输入
5 6 6 0 -2 3 4 2 1 2 1 2 2 8 9 7 8 1 2 1 -1 9 7 2 1 2
输出
9
示例2
输入
5 62 33 18 -2 85 85 73 69 59 83 44 38 84 96 55 -1 11 90 34 50 19 73 45 53 95
输出
173
分析:spfa可以过,我用的优先队列,一条路走到黑,起点time不加,最后终点time + 2即可(因为BFS+ -2了,要还原)
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6 52 :K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ 53 w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD 54 H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22aOBgEpOppZOOgG 55 iwsJsr7rsLrrLcJ2gQGXHwa1SUHBB: . ... . .., : 1BRKpOEGp2Jr;::rsXP1Uaa2U5a5aUa5SsSpgQRZGZEEZZOOgDg 56 ,cs5aXaP552ssLwRSHXaSS5asXBB. . . . LBBgGgZHsr;vrr;rcXpP5UUS5X5S2XS5SS1URBggpEZgDDGOGggRD 57 ,;irrs2KgQRPJJJSUXKXSHJpBM . . . ZBBOUsr;:. ,,,rHgZPUaSaUSUSSXaUPXsSBB6ZZp6EEGOOGDEggO 58 ;BBQQZaSJ5J15SJDQ7 .iEBL:. . .,:,:;SRQGZXPXXSHaS2UUSUSswQB6OZgG6pZZGODEOGDE 59 JgUri1aGEpEpXSS5LBQ, .rLap2Jr ;712OO6ZggRDZXHXpKK2211LLLc7wgBa2PODRGE6OZgDgGDGD 60 7QB; ,Jc76DaZXOZgDPEBBX, :c1HEZ1c;:,.,:;cHDgQQggMZgGOZO6OEGpXsLLsJXHPOBBBc;vss5EMggZDODOgED6 61 LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD 62 wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp 63 7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 330 82 #define MOD 1e9+7 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 8 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int matrix[MAX][MAX]; 92 int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; 93 int dis[MAX][MAX]; 94 int n, q; 95 96 struct Node{ 97 int x, y, time; 98 bool operator < (const Node& a)const{return time > a.time;} //priority_queue 99 }bn, en, ln; 100 101 102 bool check(int x, int y) { 103 if (x < 0 || x >= n || y < 0 || y >= n || dis[x][y])return 0; 104 return 1; 105 } 106 107 108 int BFS(){ 109 priority_queue p;ME(dis, 0);p.push(bn); 110 dis[bn.x][bn.y] = 1; 111 while(!p.empty()){ 112 ln = p.top(); p.pop(); 113 if(ln.x == en.x && ln.y == en.y) return ln.time + 2; //¼ôÖ¦ 114 for(int i = 0; i < 4; i++){ 115 Node cnt; 116 cnt.x = ln.x + dir[i][0]; 117 cnt.y = ln.y + dir[i][1]; 118 cnt.time = matrix[cnt.x][cnt.y] + ln.time; 119 if(check(cnt.x, cnt.y)){ 120 dis[cnt.x][cnt.y] = 1; 121 p.push(cnt); 122 } 123 } 124 } 125 return -1; 126 } 127 128 int main(void){ 129 // #ifdef LOCAL 130 // freopen("in.txt", "r", stdin); 131 // freopen("out.txt", "w", stdout); 132 // #endif 133 ios::sync_with_stdio(false); cin.tie(0); 134 int i, j, k, x1, y1, x2, y2; 135 136 while(cin>>n){ 137 for(i = 0; i < n; i++)for(j = 0; j < n; j++)cin>>matrix[i][j]; 138 for(i = 0; i < n; i++){ 139 for(j = 0; j < n; j++){ 140 if(matrix[i][j] == -1){bn.x = i; bn.y = j;bn.time = 0;} 141 else if(matrix[i][j] == -2){en.x = i; en.y = j;} 142 else ; 143 } 144 } 145 cout< endl; 146 } 147 148 return EXIT_SUCCESS; 149 }
链接:https://www.nowcoder.com/acm/contest/118/B
来源:牛客网
precise math function
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
喜爱ACM的PBY同学遇到了一道数学难题,已知底数n,请你帮他准确的计算出结果a = n
π(n的π次方),结果保留小数点后x位。
输入描述:
第一行是一个整数t,表示测试实例的个数;
然后是t行输入数据,每行包含两个正整数n和x,表示底数和保留位数。
(1 <= t <= 100,1 <= n <= 500,1 <= x <= 6)
输出描述:
对于每组输入数据,分别输出结果a,每个输出占一行。
示例1
输入
3 1 3 7 6 9 1
输出
1.000 451.807873 995.0
分析:这女的好可爱!!!,PI设置成acos(-1.0)即可
链接:https://www.nowcoder.com/acm/contest/118/C
来源:牛客网
颜料的混合
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
艺术家通常要通过颜料的混合得到某种他想要的但又不是从工厂里面生产出来的原始的那种颜料。为了简便起见, 我们假设每种颜料都可以分成是红绿两个分量的数值指标, 即每种颜料都可以用红绿在其中占据的百分比来表示。艺术家从工厂拿回了三种不同颜料分别是(x
1%红,y
1%绿), (x
2%红,y
2%绿),(x
3%红,y
3%绿), 问艺术家是否能够调出自己想要的颜料(x
0%红,y
0%绿)?
输入描述:
八个整数:x0
,y0
,x1
,y1
,x2
,y2
,x3
,y3
。(0 < xi
, yi
< 100)
输出描述:
输出Yes如果可以调出, 否则输出No
示例1
输入
2 3 1 1 3 3 2 4
输出
Yes
说明
一份颜料一, 一份颜料二, 一份颜料三混合即可。
备注:
输入数据有多组!
分析:23333,这题不会耶。
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1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iDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6 52 :K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ 53 w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD 54 H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;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,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 550 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 struct Point{ 91 int x,y; 92 Point(){} 93 Point(int x,int y):x(x),y(y){} 94 int operator * (const Point&tmp)const{ 95 return x*tmp.y-y*tmp.x; 96 } 97 Point operator - (const Point&tmp)const{ 98 return Point(x-tmp.x,y-tmp.y); 99 } 100 }; 101 102 bool solve(){ 103 104 int x0,y0,x1,y1,x2,y2,x3,y3; 105 if(scanf("%d%d%d%d%d%d%d%d",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3)==-1) return 0; 106 Point p[4]; 107 p[0]=Point(x0,y0); 108 p[1]=Point(x1,y1); 109 p[2]=Point(x2,y2); 110 p[3]=Point(x3,y3); 111 112 int ans=abs((p[0]-p[1])*(p[0]-p[2])); 113 ans+=abs((p[0]-p[2])*(p[0]-p[3])); 114 ans+=abs((p[0]-p[3])*(p[0]-p[1])); 115 if(ans==abs((p[1]-p[2])*(p[1]-p[3]))) printf("Yes\n"); 116 else printf("No\n"); 117 118 119 return 1; 120 } 121 122 int main(){ 123 //freopen("in.txt","r",stdin); 124 //freopen("out.txt","w",stdout); 125 while(solve()); 126 127 return 0; 128 }
链接:https://www.nowcoder.com/acm/contest/118/D
来源:牛客网
题目描述
1, 2, 3在打篮球, 可是二打一总是不公平的, 于是他们决定一对一,另一个人在边上看着, 谁输了谁就和下场和在边上看着的那个人交换。 现在给你一个胜利者的序列(每一轮胜利的人), 问这个序列合不合法。(一开始1,2单挑, 3在下面看着)
输入描述:
第一个数是数字n(1<=n<=100), 代表输入的胜利者序列的规模, 接下来的n行描述了胜利者序列。第i行包含一个正整数a[i],(1<=a[i]<=3),代表着a[i]赢得比赛
输出描述:
输出YES如果胜利者序列合法, 否则NO
示例1
输入
3 1 1 2 2 1 2
输出
YES NO
说明
第一个例子中, 1赢了2, 3代替2; 1赢了3, 2代替3; 2赢了
第二个例子中, 1赢了2, 3代替2, 这时候2明显已经在场下了故不可能为胜利者
分析:弄个a,b,c交换就好了
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXa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ZDODOgED6 61 LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD 62 wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp 63 7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 1001 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int main(void){ 92 // #ifdef LOCAL 93 // freopen("in.txt", "r", stdin); 94 // freopen("out.txt", "w", stdout); 95 // #endif 96 ios::sync_with_stdio(false); cin.tie(0); 97 int n, i, a, b, c, win, flag; 98 99 while(cin>>n){ 100 a = 1; b = 2; c = 3;flag = 1; 101 for(i = 0; i < n; i++){ 102 cin>>win; 103 if(a != win && b != win)flag = 0; 104 else if(a == win)swap(b, c); 105 else swap(a, c); 106 } 107 if(flag == 0) cout<<"NO"<<endl; 108 else cout<<"YES"<<endl; 109 } 110 111 return EXIT_SUCCESS; 112 }
链接:https://www.nowcoder.com/acm/contest/118/E
来源:牛客网
233
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
Kirai聊天的时候非常喜欢发“233”,“233”来源于猫扑表情第233号,是一张捶地大笑的表情。
Kirai每当看到很好玩的消息的时候总会回一串“2333...”。
Kirai其实十分高冷,他发现了这个问题。为了不希望别人立刻知道他在笑,他决定将两个“233..”乘在一起发出去。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤1500)。
接下来输入T组数,每组数字由两个233串组成,每个233串长度3≤n≤50。
数据保证每个233串必然会有一个2作为开头,并且3的数量≥2。
输出描述:
两个233串的乘积。
示例1
输入
2 233 233 23333333333333333333333333333333333333333333333333 23333333333333333333333333333333333333333333333333
输出
54289 544444444444444444444444444444444444444444444444428888888888888888888888888888888888888888888888889
分析:大数相乘,板子题
C++:
1 #include2 using namespace std; 3 4 #define FF(i, a, b) for(int i = a; i < b; i++) 5 #define RR(i, a, b) for(int i = a; i > b; i++) 6 #define ME(a, b) memset(a, b, sizeof(a)) 7 #define SC(x) scanf("%d", &x) 8 #define PR(x) printf("%d\n", x) 9 #define MAX 1000 10 #define M 8 11 #define N 6 12 typedef long long LL; 13 typedef pair<int, int> Author; 14 15 //±àÒëʱǶÈëµ÷Óô¦ 16 inline int max(int a, int b){ 17 return a > b ? a : b; 18 } 19 20 inline int max(int a, int b, int c, int d){ 21 return max(max(a, b), max(c, d)); 22 } 23 24 //bool cmp(const Node& a, const Node& b){ 25 // 26 //} 27 char ch1[MAX]; 28 char ch2[MAX]; 29 int num1[MAX], num2[MAX], num3[2 * MAX + 10]; 30 /*QAQ£º¿ªÊ¼Ñ§¼ÆË㼸ºÎºÍÊýѧºÍ´óÊýÎÊÌâ*/ 31 int main(void){ 32 int i, j, T, len1, len2, n; 33 34 cin>>T; 35 while(T--){ 36 //Êý¾ÝµÄ³õʼ»¯ 37 cin>>ch1>>ch2;ME(num1, 0);ME(num2, 0); ME(num3, 0); 38 len1 = strlen(ch1); 39 len2 = strlen(ch2); 40 41 //µ¹Ðò´æ´¢ 42 for(j = 0, i = len1 - 1; i >= 0; i--, j++) 43 num1[j] = ch1[i] - '0'; 44 for(j = 0, i = len2 - 1; i >= 0; i--, j++) 45 num2[j] = ch2[i] - '0'; 46 47 //´óÊýÏà³Ë 48 for(i = 0; i < len1; i++) 49 for(j = 0; j < len2; j++) 50 num3[i + j] += num1[i] * num2[j]; 51 52 //½øλ 53 for(i = 0; i < len1 + len2 - 2; i++) 54 if(num3[i] >= 10){ 55 num3[i + 1] += num3[i] / 10; 56 num3[i] %= 10; 57 } 58 59 for(i = len1 + len2 - 1; i >= 0; i--) 60 if(num3[i] != 0) 61 break; 62 63 for(; i >= 0; i--) 64 cout<<num3[i]; 65 cout<<endl; 66 67 } 68 return 0; 69 }
python3:
1 t = int(input()) 2 while t > 0: 3 n,m = map(int,input().split()) 4 print(n*m) 5 t-=1
链接:https://www.nowcoder.com/acm/contest/118/F
来源:牛客网
扫雷
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
《扫雷》是一款大众类的益智小游戏,于1992年发行。游戏目标是在最短的时间内根据点击格子出现的数字找出所有非雷格子,同时避免踩雷,踩到一个雷即全盘皆输。当某个位置为数字的时,代表它周围的八连通区域中有对应数量的雷。
kirai获取了简化版扫雷(没有标记雷的小旗)的后台数据(后台数据包括所有数字和雷的位置),转换为一个n*m(1≤n, m≤500)的矩阵并对格子类型做了如下标记:
雷被标记为'*';
点开的空白区域标记为'0';
未点开的空白区域标记为'.';
数字1~8代表周围有多少雷;
kirai非常笨,他希望你帮他完成这样的任务:
给定k(1≤k≤min(可扫位置数, 10))个位置坐标和扫雷游戏的后台数据,输出点开指定位置序列后游戏的结果,初始时游戏中没有点开任何位置。
注:数据保证扫雷过程中不会重复点击已扫位置。
输入描述:
输入样例有多组,全部是正整数。首先输入样例组数T(T≤10)。i
接下来输入T组数,每组数据第一行包括四个正整数n,m,k(1≤n, m≤500, 1≤k≤min(可扫位置数, 10))分别表示地图的行、列数和即将点开的位置数。紧接着是一个n*m的矩阵,代表扫雷的后台数据,。
矩阵后是k个整数对x
, yi
(1≤i≤k, 1≤xi
≤n, 1≤yi
≤m),表示依次点开的位置。
输出描述:
如果某一步踩到雷,输出"Game over in step x"(不包括引号",表示第x步踩中雷);未踩到雷则根据扫雷的游戏规则更新,并输出最后一步结束后显示给kirai的矩阵。
示例1
输入
1 5 5 3 2*11* *2111 22... *1... 11... 1 1 3 3 1 2
输出
Game over in step 3
说明
2....
.....
.....
.....
.....
2....
.2111
.2000
.1000
.1000
Game over in step 3
分析:模拟下就好,数字就是单个标记,炸弹可以直接标记退出,空白地方要DFS全部标记,然后总的循环把周围8个方向标记,最后输入标记的点,没标记的输入‘.’,这里DFS范围弄错了,尴尬,这次比赛被板子卡了好久
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6 52 :K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ 53 w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD 54 H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22aOBgEpOppZOOgG 55 iwsJsr7rsLrrLcJ2gQGXHwa1SUHBB: . ... . .., : 1BRKpOEGp2Jr;::rsXP1Uaa2U5a5aUa5SsSpgQRZGZEEZZOOgDg 56 ,cs5aXaP552ssLwRSHXaSS5asXBB. . . . LBBgGgZHsr;vrr;rcXpP5UUS5X5S2XS5SS1URBggpEZgDDGOGggRD 57 ,;irrs2KgQRPJJJSUXKXSHJpBM . . . ZBBOUsr;:. ,,,rHgZPUaSaUSUSSXaUPXsSBB6ZZp6EEGOOGDEggO 58 ;BBQQZaSJ5J15SJDQ7 .iEBL:. . .,:,:;SRQGZXPXXSHaS2UUSUSswQB6OZgG6pZZGODEOGDE 59 JgUri1aGEpEpXSS5LBQ, .rLap2Jr ;712OO6ZggRDZXHXpKK2211LLLc7wgBa2PODRGE6OZgDgGDGD 60 7QB; ,Jc76DaZXOZgDPEBBX, :c1HEZ1c;:,.,:;cHDgQQggMZgGOZO6OEGpXsLLsJXHPOBBBc;vss5EMggZDODOgED6 61 LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD 62 wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp 63 7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 550 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int n, m; 92 int dis[MAX][MAX]; 93 int dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; 94 char matrix[MAX][MAX]; 95 char mymatrix[MAX][MAX]; 96 97 int DFS(int x, int y){ 98 if(x < 1 || x > n || y < 1 || y > m || matrix[x][y] != '.' || dis[x][y] == 1) return 0; 99 dis[x][y] = 1; 100 DFS(x + 1, y); DFS(x - 1, y); DFS(x, y + 1); DFS(x, y - 1); 101 return 0; 102 } 103 104 105 int main(void){ 106 ios::sync_with_stdio(false); cin.tie(0); 107 int i, j, T, k, ix, iy, flag, index; 108 109 cin>>T; 110 while(T--){ 111 cin>>n>>m>>k; ME(dis, 0);flag = 1; index = 0; 112 for(i = 1; i <= n; i++)for(j = 1; j <= m; j++)cin>>matrix[i][j]; 113 for(i = 1; i <= n; i++)for(j = 1; j <= m; j++)mymatrix[i][j] = '.'; 114 for(i = 1; i <= k; i++){ 115 cin>>ix>>iy; 116 if(matrix[ix][iy] == '*' && flag == 1){flag = 0;index = i;} 117 else if(matrix[ix][iy] == '.')DFS(ix, iy); 118 else dis[ix][iy] = 1; 119 } 120 for(int x = 1; x <= n; x++)for(int y = 1; y <= m; y++)if(matrix[x][y] == '.' && dis[x][y] == 1)dis[x - 1][y - 1] = dis[x - 1][y] = dis[x - 1][y + 1] = dis[x][y - 1] = dis[x][y + 1] = dis[x + 1][y - 1] = dis[x + 1][y] = dis[x + 1][y + 1] = 1; 121 if(flag == 0)cout<<"Game over in step "< endl; 122 else{ 123 for(i = 1; i <= n; i++){ 124 for(j = 1; j <= m; j++){ 125 if(dis[i][j] == 1 && matrix[i][j] != '.')cout<<matrix[i][j]; 126 else if(dis[i][j] == 1 && matrix[i][j] == '.') cout<<"0"; 127 else cout<<mymatrix[i][j]; 128 } 129 cout<<endl; 130 } 131 } 132 } 133 134 return EXIT_SUCCESS; 135 }
链接:https://www.nowcoder.com/acm/contest/118/G
来源:牛客网
火车上的2连座
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
程序员A和B要去一起坐火车,这列火车上的每一排都有4个座位,而且这四个座位
被过道分成了两半。当A和B到了车上时,一些位子已经有人了。
A和B是好基友,于是他们想要找一对连在一起的座位。两个连在一起的座位是同一排但是不被过道隔开的两个座位。给定一列火车上的座位情况,请你寻找一下能否找到一对连座?
输入描述:
每组样例第一行为一个整数n,1<=n<=1000,表示火车一共有n排座位。
之后的n行每行为一个含有五个字符的字符串,第i个字符串的五个字符表示第i排座位的情况。每一个字符串的第三个字符都为字符‘|’,表示过道,其余每个字符表示一个座位的占用情况。字符'O'表示座位为空,字符'X'表示座位上已经有人,即被占用。
输出描述:
如果能够找到一组连座,则先输出一行字符串“YES”(不要输出引号)在第一行,在接下来的n
行输出车的座位情况,除了A和B的座位用字符'+'表示,其余输出格式与输入格式中车的座位情况一致。
如果不能够找到一组连座,仅输出一行“NO”(不要输出引号)即可。
有多组座位安排方式时,将A和B安排在前面的排,如果同一排还有两组可行解,选择将A和B排在左边。
例如一组车的情况为这样的时候,应该将其安排为箭头右边的情况。
OO|OO --> ++|OO
OO|OO --> OO|OO
示例1
输入
6 OO|OX XO|XX OX|OO XX|OX OO|OO OO|XX 4 XO|OX XO|XX OX|OX XX|OX 5 XX|XX XX|XX XO|OX XO|OO OX|XO
输出
YES ++|OX XO|XX OX|OO XX|OX OO|OO OO|XX NO YES XX|XX XX|XX XO|OX XO|++ OX|XO
说明
注意
第一组样例中,下面的安排是不合法的。
O+|+X
XO|XX
OX|OO
XX|OX
OO|OO
OO|XX
分析:水题,但是这妹子很好看、QAQ
1 /** 2 3 :;LaEaH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U6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6 52 :K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ 53 w; ,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r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 1001 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 char seat[MAX][5]; 92 int main(void){ 93 #ifdef LOCAL 94 freopen("in.txt", "r", stdin); 95 freopen("out.txt", "w", stdout); 96 #endif 97 ios::sync_with_stdio(false); cin.tie(0); 98 int i, j, n, flag; 99 100 while(cin>>n){ 101 flag = 1; 102 for(i = 0; i < n; i++){ 103 cin>>seat[i]; 104 for(j = 0; j < 5; j++){ 105 if(seat[i][j] == 'O' && seat[i][j + 1] == 'O' && flag){ 106 flag = 0; 107 seat[i][j] = '+'; seat[i][j + 1] = '+'; 108 } 109 } 110 } 111 if(!flag){ 112 cout<<"YES"<<endl; 113 for(i = 0; i < n; i++){ 114 for(j = 0; j < 5; j++)cout<<seat[i][j]; 115 cout<<endl; 116 } 117 } 118 else cout<<"NO"<<endl; 119 } 120 121 return EXIT_SUCCESS; 122 }
链接:https://www.nowcoder.com/acm/contest/118/H
来源:牛客网
程序员的好印象
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
有一个程序员做过 n 个项目,他想要跳槽,因此他想要给面试官留下一个好印象。于是他想使自己看起来很有潜力也相应的会有竞争力,于是他决定从自己以前做过的N个成功或者失败的项目里不改变原来的时间顺序从中选择若干个项目,使得他展示出来的任意一个成功的项目之后都不会有一个失败的项目。这样一来,能够表现出他十足的潜力:尽管一开始做项目会失败,但一旦学会之后就不会再失败。具体的来说,给定一个含 n 个数字的“01”序列,如一个含5个数字的“01”序列:0 0 0 0 1,其中0代表失败的项目,1代表成功的项目。即第一个0代表第一个失败的项目,第二个0代表第二个失败的项目......最后一个1代表第五个成功的项目。于是如果这个程序员将选取一个原序列的一个子序列 0 0 0 0,满足上面他的要求:任意的数字1之后都没有数字0出现。程序员的目的是为了在满足上面的要求的条件下尽可能的展示最多的项目,请帮他算最多能展示多少个项目。
输入描述:
每组样例第一行为一个整数n,1<=n<=100,第二行为n项的01序列,每一项之间用一个空格隔开。
输出描述:
输出一个正整数,表示最多能展示的项目个数。
示例1
输入
4 1 1 0 1 6 0 1 0 0 1 0 1 0
输出
3 4 1
分析:求最长不降子序列,暴力应该也可以过,水题,总共才100个长度,二分或者直接upper_bound就可以了,如果求最长不升子序列,就把if换一下,upper_bound换成lower_bound即可
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX5XaHU55K2wUGMRZ6Z6 52 :K :7asvwc2MgEQB, :gg.:iB7 .,,,:. ...,. . .. .:iM6GEpSSXZOEs:...;spZpKKXXSX5Xa5Ja5wwKGQDEpp6OZ 53 w; ,LXLr77sLwL5aR. gRgQgaQBi ,vJwvi,. .;;:;7: . . ,... rRDRJUSXpgas:,.:;U66SaHa2X5aUa552X12SgQgpZpEpGOD 54 H: ;XJ;77rv7rJUaQ;rgaPgXXHBB; . . .ri:;; ,: . :6QZEKHXpXXL:,::r1PKXaa2XSS5a5S5UJ22aOBgEpOppZOOgG 55 iwsJsr7rsLrrLcJ2gQGXHwa1SUHBB: . ... . .., : 1BRKpOEGp2Jr;::rsXP1Uaa2U5a5aUa5SsSpgQRZGZEEZZOOgDg 56 ,cs5aXaP552ssLwRSHXaSS5asXBB. . . . LBBgGgZHsr;vrr;rcXpP5UUS5X5S2XS5SS1URBggpEZgDDGOGggRD 57 ,;irrs2KgQRPJJJSUXKXSHJpBM . . . ZBBOUsr;:. ,,,rHgZPUaSaUSUSSXaUPXsSBB6ZZp6EEGOOGDEggO 58 ;BBQQZaSJ5J15SJDQ7 .iEBL:. . .,:,:;SRQGZXPXXSHaS2UUSUSswQB6OZgG6pZZGODEOGDE 59 JgUri1aGEpEpXSS5LBQ, .rLap2Jr ;712OO6ZggRDZXHXpKK2211LLLc7wgBa2PODRGE6OZgDgGDGD 60 7QB; ,Jc76DaZXOZgDPEBBX, :c1HEZ1c;:,.,:;cHDgQQggMZgGOZO6OEGpXsLLsJXHPOBBBc;vss5EMggZDODOgED6 61 LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD 62 wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp 63 7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 110 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int main(void){ 92 // #ifdef LOCAL 93 // freopen("in.txt", "r", stdin); 94 // freopen("out.txt", "w", stdout); 95 // #endif 96 // ios::sync_with_stdio(false); cin.tie(0); 97 98 int i, j, a[MAX], b[MAX], n, len; 99 100 while(cin>>n){ 101 for(i = 1; i <= n; i++) cin>>a[i];ME(b, 0); 102 len = 1; b[1] = a[1]; 103 for(i = 2; i <= n; i++){ 104 if(a[i] >= b[len]) b[++len] = a[i]; 105 else{ 106 j = upper_bound(b + 1, b + len + 1, a[i]) - b; 107 b[j] = a[i]; 108 } 109 } 110 cout< endl; 111 112 } 113 114 return EXIT_SUCCESS; 115 }
链接:https://www.nowcoder.com/acm/contest/118/I
来源:牛客网
郊游
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
2018年萌新刚升为队长,于是带领校队的n名队员一起去郊游,他选定的地点与学校的距离为l米。
为了更快达到目的地,萌新计算了经费后为大家租赁了一辆限乘k人的车,队员们都非常不满,但对于萌新队长敢怒不敢言。
现已知队员走路的速度为v 1,车的速度为v 2,每位队员只能上车一次。
你的任务是帮助萌新确定到达目的地所用的时间(保留10位小数,考虑上车下车、车掉头时间不计)
输入描述:
第一行输入一个整数m,代表m组数据。1
接下来m行,输入5个正整数n,l,v
,v2
,k。9
其中1≤m≤1000,1≤n≤10000, 1≤l≤10
, 1≤v1
2 ≤109, 1≤k≤n输出描述:
输出一行,为一个实数。代表萌新确定到达目的地所用的时间(保留10位小数,考虑上车下车、车掉头时间不计)示例1输入
1 3 6 1 2 1输出
4.7142857143分析:小学生数学题 http://www.1010jiajiao.com/xxsx/shiti_id_730fe4de7fddc8a4573057ef03462705
真刺激啊,我可能要重读幼儿园了!!就是要分段,车要保持最短时间,就要在半路上停车,下人,回去再接人,最后都能一起到终点
View Code1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDggQgOHgMGL, .;PEHHXaaKaPXPKPaXS 49 s7.:,sBa :..S, vE::::; 7BBMgZH6pQBr . ,:, ,.,r2RHSSpMZPKRRZpgggav, ;UpEZaaaKHHUHPPaUJHGO 50 a;.775: .::rU. gR:,:. :;:BBBBQar . ,, ,.,7rggJwU6DDGMgOGgXc:, ,rPGOpKSXSXSKUKHU1UHgOEP 51 1i :SZJrLXpBBMRB: .v Ba,. :sv: . irsBUSpEEGPPpg65r:..,;sKZDZHSX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BBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 1001 82 #define MOD 1000000007 83 #define E 2.71828182845 84 #define PI 3.14159265358979 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int main(void){ 92 int T; 93 94 cin>>T; 95 while(T--){ 96 double n,s,vr,vc,k; 97 int a,b,c,d,e; 98 scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); 99 n=a,s=b,vr=c,vc=d,k=e; 100 int p=(n+k-1)/k; 101 printf("%.10lf\n",vr 1)*(vc-vr)/(vc+vr))*s/(vr*(p+(p-1)*(vc-vr)/(vc+vr)-1)+vc):s/vr); 102 } 103 104 return EXIT_SUCCESS; 105 } 链接:https://www.nowcoder.com/acm/contest/118/J
来源:牛客网过河时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
现在萌新要乘船度过一条河,这条河宽为s米。现已知船相对于水的速度为v 1,水流的速度为v 2。
由于萌新想到达起点的正对岸,所以他会一直调整船行驶的方向朝向正对岸。
你的任务是计算萌新将用多少时间度过这条河;若他不能到达起点的正对岸,输出“Infinity”。
输入描述:
第一行输入一个整数n,表示测试用例数;1
接下来n行,每行输入三个整数s、v、v2。1
其中,1≤n≤1000,0≤s≤100, 0≤v,v2≤100。输出描述:
输出一个实数,你的任务是计算萌新将用多少时间度过这条河(保留10位小数);若他不能到达起点的正对岸,输出“Infinity”。示例1输入
3 2 2 2 2 4 3 5 6 5输出
Infinity 1.1428571429 2.7272727273分析:HDU5761:http://acm.hdu.edu.cn/showproblem.php?pid=5761,数学积分求解,这题意是它船要到正对岸(竖线)且船头要'
也要是竖线,所以要不断调整方向
1 /** 2 3 :;LaEaHKEEGpPXU7;, 4 .:75pKH11252U252XapZgRQgD6XJscLr;,. 5 :LXpRgGaX521JLw1JswJJsJs22XHPPEZEGDOMMRDOa7. 6 .r2EDDZEpZPZP6KpHX5SXH5XXa5KwaXaSX5UJ1c77sLs2GMQQ6r . 7 ,LpgOGpEZGZEZEpZKpHHU5wP5HEDgpXpHa2SSa5aSXULr7rrirrJXRBp; ;B 8 ,J6MRZH6EgEEZE6E6EZZPZXXwSSGQXr::aPpP5USUHaHaKa5Lvrr7ri;rLHBB2: Kc 9 rpQDOpPPOGGZOGOZG6GEOEOEDPPGBa. .PaSSUXSUUUaUSaKXKS177r7rrrirSBBR7 .O, 10 :UBQOKPK6ZOOOEDEO6GZE6EpEpDgDBR: UBpXHa5aSaUS5SUS5XapPHJc7rrv7rr7sgBBs .g. 11 ;gBMPXpO6GEOEOEOEGEOEE6EZEEDRGBB EB5pKSXpHKaHSX552S5aUHHEX17c7vr7777s5RBS: .R; 12 .sQBPXpDZOODOgODGOGgEDEOEOGgGgOOMB: LBKKSXSHa52aaKXHXKaa5aSaaHXSJLcL7vcc777JDBBg2;. Qi 13 ;2ggp2EDDOggGEDGgDDOgGGZDOOZOGg6gEBX vBZaHUKaaUXXXSXXKXpXHXH5wwaa52U1wssLsLJccv1UDQBQ67. O7 14 :ZZUU5PROOEOZOZGGOODZOGgODZOOgOggRgRB; ;:..R6XaKKpP6PGppKPHpHpPX5aU21UUa5Sw52UwUJJv77L77sSpQMDU; ;B5 15 ,SRJ7sSHGggEOZOEG6OODpOZgggOQQBBBBBQBBQ.,;;. LBOgOgDRDDZODMgQRgRDaa552a252UUa25w5UaU2sLvccs7r7sJZBBMr ,XQJ: 16 LQHr77J6RGOZDZOEGEDGgDRORQBBBQRDPU1Jscwa7.,::.:J7r;::::. ..,:;i7UOgRRRgDPH5SUSU52U2HHa1JJJLJLccLr71RBB, 7R2, 17 :RZv;77JSgGOZEODEDGOEggQBBBMS7;:,:,,.,.,.:7L;:,;.: ,: . ..... .:;rJU6GgGRggEZHPaKXX2S221Js1Lc7r:7QB. .XX: 18 7g1;;7rcXG6gpGDZGgZOOQBBQpr. ::::;:;:::Jr::sr;::;:.:vs,:::::::::::,, ,:7L5HGOggRgZUUU5wSUaJLc7r7BOiDr ... 19 .XX;;;irLHGKpZZZEKgDRBBB6i ,;;:;;;;r;;:s177:,;L7:;7:.rHi,:::::::::::::::::,. .,;7ZRQgO6KUUJsLwsJ7KBM. ..... 20 JZ:;rrrc5EPHp6XgpRBBBE; :i:;;;;;:;;;:c7::r7;,::::::::rv:,:::::::::::,:,:,:,,,, .;sORQRGX21wsXU: .... . 21 .Br;iir72EHPHZ6EgBBR7. ..;ii:;;;;;;;;;:71r::.:7, .::7;:;H;.::,:j::::::,:::::,,,::,,, ,7wEDRZBMr ....... 22 1D;:r;rwOPXPKH6BBX, .:;:;;;:::;:;;;;;::Ls,;ss..r. ,c77;sLU,:,:::,:::,:,:,:,,,:,,,:::. .:.rP:....... 23 D2:i;rJpKHXHXgg7 .,,::::;:::::;:;:;;:;SL7sS2, :. ::::,:U7.:::,:::,:,,,,,:,,.,,,.,:, ;L:. .. ... 24 :Qc;i7LGZPa6gBM, ...,,::::::::::::;;::;.JJ;ic: ;:::,v1,.:::;7,,,:,:,:,,,,.:,,,,.. :2wr. ....... 25 sRr:rrwZGgBQR7. .,,::::::::::::::;::;:::Hr:7i ,;;:::U: .,,,:r.,,:,:,:,,,:,,,..... 7K2:. .......... 26 OX:irsXgQZ:. .,,:::,,:::,::::::::;;;::r5;r7: :;;;:7L ..,.,;:,:,:,,,:,:,,,,...... .rU6w;.............. 27 .BJ71EK5;. .,,::,:,:,,,:,:,::::::::;:;.Ls;r7 :;:::s, ..,,,r:.:.,,,.:, .,..... . .;s5XJr,..,............. 28 1Mv::. .:,:,,,,,,,:::::::,;:::;:;::..J7;c: ,. ,rri:27 , .,:;. ,:,:,,:..,.... .rpPL;:.. ... ............. 29 ..7Ls: .,,,:,,,:,:,:::,:,:::::,:::::: .Srrr, .,:;;;::::..:7r;r1 .: :E:..,,:,...,,.., ..XBQ7, ................... .. 30 ,;7v7r7:, ,,,,:.,,,,,,:,,::,:,,.::.,:.,:, :Jrr; ,r7,:.. ,:::L: . .7RJ .,.:.,......,,:MBs ..............,........ 31 .:;vJs7i, ,,,., ..,,:,,,:,,,:,:.,rs,,.:,, ;J;c, .,::;; Lr.E: .,...,....:,:1Z: .........,.,...........:,. 32 .;,,:r7J1wv;,. ....,.:. .,.,,:,,,:,,::::,sS;.:::, cLrr. . .,. .,..: ;; r5 ........,,:;s7. ....,.,.,...........,.,.,,. 33 ,BBs::: . ........,.,,,,,.:,,,:,:,,.;s7r,,,,, cc7; ,.,,. .:7rrJGMPOEL1, ..... ,,:rSr, : ,.,.,.,.,.........,,,,,. .. 34 rZL. ....... ..,,,.,,,..,,,.,;,...7J:s: .. .wr7, ... .rJpQBBBBBBBQgKP77s .. .,7S2,,....,....,.,.,......,,.,. .:cX2 35 ;SH7, . . . .. .,.,.,.,,,...,..r, ::Ur;7L . .57;. .rPBBQBBBPws:;r::::.,:P. .;S5;,..,...,.,.,.,.... ..,,, ..,7HSJvr 36 r7r;: . ... ..........,...,.. 7L;,rS;;ivr . 1r: . .rZBBK7;.JL,::Jrs;.:;,:;J, .,;LDv..:.,...,.,.,.,...,.,,:,, ,7sKGwc77; 37 .:7L7:, . ,r,..,.,,,...,..:iLL 7s;r;cv: U7. :vi;:. .. :Er:::.Ls. . ,7::::vHEi ,:,,.,,,.,.,,,,,,::::, .:1QBKJJUsssc 38 .:rvw1JsL7;, ,;..........,.:ir :r .ELr77v:,. Pr .. . Ls ,w. rr.r:JPr. ::,..,,,.,,,,:,:::,:,..7XgRE52US25w1c 39 .:;7JRQpX: ; .........,i: .,J ;gri;7r : 1; .X: . ,v :aK1, ,,:.,,,.,,,,:::::,;::::cOBB6K55UXUX5XUw 40 ;J,XQB7,: . ...,: .:7Z.7Zi7;r: , v, :w:;,.,:::7LUsc:..:,:.:,,,,,:,:::::::,:;c5BBPS5wSUSUaUaUa2 41 J7 rEBBg..,. ..... . ,L1PLKr:,:;r;;::, :, :;SXsJU1XLLr....:,,,,,,::::,::::::,::LL,,rZXUJU25552aUUUU 42 JL .:sXBB:... ., . ,OH777;,rZRBBBQL ..r, ,:r7::r:,;;....:,,,,,,,,.::::;::;:::.7gL UK2UUS1aw2wU25J 43 U7 .r71BB; . :.. .. :QJ;.;1pBBBBBGRBRi i: . .w7. ..,,:,,,,,:,:,:::::::,.,2BR: .DSaUSUUS525w5U1 44 2r :7rJBQ7 .;. . KL::JGBBBgE6Hp6XMQ; . ... ,2s ,,,,:::::,:::::::,,.:sQQB2 ;DHa5U52S2U25USJ 45 a: :7;1BB2 .v, sL;LPQgDBPH6KPQBpGBG . ... .. aP:. .. ,::,:::::,,,,.;rSgBQDa; :gSSwSUUU525US2U 46 5; ;;r2QBB, .s: :a7:PBZ2,:BEaZPKgBZOgB, . ...:LEHri::,:.,,.,,,::rsXRBgGKEJi, 2GH252SUS5S11wH5 47 U: ;:rwDBBr .c, rB6r 167.,,RQPpEP6OpKEBc ., . : ::sS7;cKB6HHa1XOQRRQBRgEZDBH; .. ;RZUPSSU525USSpK2 48 s; ;::aBg, .; .Gv,H::,,::,;BQDOGHPXpKBs .,. . .,. .r:;:6gOEBQRRRDgg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sJXHPOBBBc;vss5EMggZDODOgED6 61 LZJ::iwrrr72EPgXU5OBBBBBBBp7: .i5P6wL;, .:LS6DMgMgZKgEOPOGGDDGEXULvLSOBBBBBQBgDQDJ5rrr7JOQQDDZGEgDD 62 wp rR5, .HQRX7r72RQBBBBBQBMEK6Uc7sc7cHOU:, .:LHgOQg6ZOPZpZGGEDERZPwcr7LKDDaJr:. rBX;;:r:ir1DBQMgRgDp 63 7D,sw: , Z. .LgBBQBBOsJaQBBBBBBXrr. .:rwZBBQgROgDgDOERRMgROOScrLsPP5r, 7Qs,::::::rUgRgZOG6 64 ,Q57:r ,: ,r U: .;; .vL7L;r:UG7.:sr;JSgQBgDEZXXUSXpHa21svr7r7s2v:. iQK...:,:::;LLJJws 65 OBHs;. :;;,v H: :6X; rpL;7pSrrr7r;::,....,,:;iirrvvvr, :BBPs;;:,,,,::;:: 66 ::rPDEL:..7:c;7r pK .: :KL.:r:.. ..:icsS5sr:,. JgGgBQDOSJss77r 67 :r;::: , PH r, ,;5: ,::::;7Ls7Lc7;: ,:7JP17rJUs 68 .:J: :; .,:K6BQS7:.,.,. 69 :r7Ji;r7;::;;. 70 . **/ 71 72 #include73 using namespace std; 74 75 #define FF(i, a, b) for(int i = a; i < b; i++) 76 #define RR(i, a, b) for(int i = a; i > b; i++) 77 #define ME(a, b) memset(a, b, sizeof(a)) 78 #define SC(x) scanf("%d", &x) 79 #define PR(x) printf("%d\n", x) 80 #define INF 0x3f3f3f3f 81 #define MAX 1001 82 #define MOD 1e9+7 83 #define E 2.71828182845 84 const double PI = acos(-1.0); 85 #define M 8 86 #define N 6 87 typedef long long LL; 88 typedef pair<int, int> Author; 89 vector string, int> > VP; 90 91 int main(void){ 92 ios::sync_with_stdio(false); cin.tie(0); 93 int T;double s, v1, v2, t; 94 95 cin>>T; 96 while(T--){ 97 cin>>s>>v1>>v2; 98 if(s == 0) cout<<fixed< 10)<<0.0<<endl; 99 else if(v2 >= v1) cout<<"Infinity"<<endl; 100 else{ 101 t = s / (v1 * v1 - v2 * v2) * v1; 102 cout<<fixed< 10)< endl; 103 } 104 105 } 106 return EXIT_SUCCESS; 107 }