poj 1083 Moving Tables

来源:互联网 发布:统计字数的软件 编辑:程序博客网 时间:2024/04/29 08:15

测试数据

10101 23 45 67 89 1020 2224 2628 3032 3436 38102 34 56 78 910 1112 1314 1516 1718 1920 211010 30020 29030 28040 27050 26060 25070 24080 23090 220100 2104097 182316 32191 6299 379246 396320 298153 192211 40238 13958 312285 179282 39386 221297 232256 31376 121114 274118 227168 123178 196243 16753 10315 39146 152259 141222 14466 24769 117349 335338 359217 68262 277106 43326 77170 33655 71202 49208 294223 138321 23750107 269221 316356 35728 321363 25867 121115 337215 1583 9144 249209 21962 33014 11152 247251 367150 292159 393239 4589 320349 2966 168145 8274 3147 6417 317240 16292 246133 243386 2258 5354 384383 25316 14159 4379 34379 368364 34760 69261 29541 6538 4910 30512 25944 172124 8355 304204 306353 200351 29495 2160243 351202 272396 242199 236359 18354 44209 2324 155191 78204 311142 280366 269283 1719 86380 25852 106135 28216 382302 350254 98255 34195 289136 21195 97212 198343 13950 8747 14682 175332 328165 349286 233185 144131 392173 7164 214126 13781 89170 310333 993 20633 105141 215348 12232 182151 18610 36280 241259 336338 63250 174228 36153 290205 31841 265220 292181 337334 251248 17790 307054 25288 341390 264383 141231 257371 175235 164118 338260 360238 156188 7651 278397 291393 268151 3420 11221 395137 53153 31638 303209 62342 382206 49348 337261 392387 20258 119212 294305 120236 36157 239208 122364 270315 147224 312300 25299 3267 180200 131100 179366 35384 7772 302344 329336 372143 380136 275170 26217 158250 30621 227165 2388 357335 304349 323340 14545 111222 182280 24320 123328 21310 29729 286244 130253 378190 31282 4666 199223 104374 27780307 13382 247329 976 90348 216182 133134 15131 30244 109333 303153 312297 308322 36352 210326 105151 2008 209250 117208 351244 129263 240115 286374 2711 338310 30350 245252 358169 26195 111101 191187 2912 42392 147272 180258 25157 152270 205313 178224 223300 294309 74304 239301 93321 25550 397164 383370 107284 10293 49339 342125 16051 287353 37873 36967 334393 112400 39876 13960 21519 116324 305174 278213 256249 4571 88254 150340 82138 357330 336319 106142 228218 154363 282217 354318 229171 17226 20720 38423 395290 34790275 95343 386232 383152 340217 202321 368147 117351 1332 23476 37296 272169 18970 335238 26990 328119 166279 28489 14362 394108 29215 164298 80338 264163 3863 21288 91214 193240 373317 223176 286157 364270 384267 399161 2927 162274 12511 295337 150188 2094 229170 248296 362366 53136 17281 192256 113396 141186 245320 200129 127178 68291 2354 83205 67220 22882 57367 60142 55304 23643 59361 22235 318148 219356 195285 345314 38277 3708 24175 181100 81307 105185 14215 95 6466 3574 19844 75106 1816 13973 226374 339282 27319 88218 65121 109137 69253 341306 397225 158250 45100355 297201 396144 53236 210369 77392 12163 1551 22213 374104 242351 216349 13091 54281 47162 246219 6360 168303 31769 52300 110391 385151 327342 293161 301153 335126 94262 185228 40220 112263 241395 58170 187257 105264 218197 224232 207100 274379 29937 78382 25579 146152 302102 14033 296259 16741 164316 338325 143226 346273 367356 336156 238186 9258 1387 17158 29562 229389 165288 184275 2984 139214 160141 315285 380287 8619 234390 10250 31268 37548 343206 114239 119115 106341 166245 24026 171360 372337 116188 9964 29179 134333 30422 268340 11182 28238 61118 27371 363328 398271 364350 95243 16983 31956 172249 19844 283181 71203 117149 111277 305table.out10 20 100 230 210 310 350 440 440 530



code:

#include <iostream>#include <stdio.h>#include <cstring>#include <algorithm>using namespace std;int n;#define MAX_N 401struct point{int s;int t;}POINT[MAX_N];bool cmp(const point & a,const point &b){return a.s < b.s;}int Move[MAX_N];int main(){int t;cin>>t;while(t--){int minret = 0;memset(Move,0,sizeof(Move));cin>>n;for(int i=1;i<=n;i++){cin>>POINT[i].s>>POINT[i].t;POINT[i].s =(POINT[i].s + 1)/2;POINT[i].t = (POINT[i].t + 1)/2;if(POINT[i].s > POINT[i].t){int tmp = POINT[i].s;POINT[i].s = POINT[i].t;POINT[i].t = tmp;}//保持线段左端s小于右端坐标t}sort(POINT+1,POINT+n+1,cmp);for(int i=1;i<=n;i++){int s=POINT[i].s;int t=POINT[i].t;int j=0;//根据t找第一个不重叠的for(;j<MAX_N;j++){if(Move[j] < s)break;}//放在第j层Move[j] = t;}for(int j=0;j< MAX_N;j++){if(Move[j])minret++;elsebreak;}cout<<minret*10<<endl;}}