답안 #20650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20650 2017-02-13T07:17:22 Z model_code 장애물 경기 (KOI16_dd) C++11
64 / 100
0 ms 2368 KB
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<set>
#include<cassert>
using namespace std;
 
struct lin {
int x, y1, y2;
bool operator< (const lin& c) const {
return x < c.x;
}
}ba[101010];
 
struct st {
int y, val;
bool operator< (const st& c) const {
return y < c.y;
}
}sim;
 
set<st> sets;
set<st>::iterator it;
 
int n, sy, tx;
 
int main() {
int i;
 
scanf("%d%d%d", &n, &sy, &tx);assert(n<=1000);
for (i = 0; i < n; i++)scanf("%d%d%d", &ba[i].x, &ba[i].y1, &ba[i].y2);
sort(ba, ba + n);
 
sim = { sy,0 };
sets.insert(sim);
for (i = 0; i < n; i++) {
st im; int lmin = (int)1e9, rmin = (int)1e9;
sim = { ba[i].y1,0 };
it = sets.lower_bound(sim);
if (it == sets.end())continue;
 
vector<int> v;
for (; it != sets.end(); it++) {
im = *it;
if (im.y > ba[i].y2)break;
v.push_back(im.y);
if(im.y < ba[i].y2)
lmin = min(lmin, im.val + im.y - ba[i].y1);
if(im.y > ba[i].y1)
rmin = min(rmin, im.val + ba[i].y2 - im.y);
}
for (unsigned int j = 0; j < v.size(); j++)
sim = { v[j],0 }, sets.erase(sim);
 
if(lmin < (int)1e9) sim = { ba[i].y1,lmin }, sets.insert(sim);
if(rmin < (int)1e9) sim = { ba[i].y2,rmin }, sets.insert(sim);
}
 
int ans = (int)1e9;
for (it = sets.begin(); it != sets.end(); it++) {
if (ans > (*it).val)ans = (*it).val;
}
printf("%d\n", ans + tx);
 
vector<int> v;
for (it = sets.begin(); it != sets.end(); it++) {
if (ans == (*it).val)v.push_back((*it).y);
}
printf("%d ", v.size());
for(i = 0; i < v.size(); i++) printf("%d ", v[i]);
puts("");
return 0;
}

Compilation message

dd.cpp: In function 'int main()':
dd.cpp:69:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
 printf("%d ", v.size());
                       ^
dd.cpp:70:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(i = 0; i < v.size(); i++) printf("%d ", v[i]);
              ^
dd.cpp:30:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf("%d%d%d", &n, &sy, &tx);assert(n<=1000);
                              ^
dd.cpp:31:71: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 for (i = 0; i < n; i++)scanf("%d%d%d", &ba[i].x, &ba[i].y1, &ba[i].y2);
                                                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2364 KB Output is correct
2 Correct 0 ms 2364 KB Output is correct
3 Correct 0 ms 2364 KB Output is correct
4 Correct 0 ms 2364 KB Output is correct
5 Correct 0 ms 2364 KB Output is correct
6 Correct 0 ms 2364 KB Output is correct
7 Correct 0 ms 2364 KB Output is correct
8 Correct 0 ms 2364 KB Output is correct
9 Correct 0 ms 2364 KB Output is correct
10 Correct 0 ms 2364 KB Output is correct
11 Correct 0 ms 2364 KB Output is correct
12 Correct 0 ms 2364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2364 KB Output is correct
2 Correct 0 ms 2364 KB Output is correct
3 Correct 0 ms 2364 KB Output is correct
4 Correct 0 ms 2364 KB Output is correct
5 Correct 0 ms 2364 KB Output is correct
6 Correct 0 ms 2364 KB Output is correct
7 Correct 0 ms 2364 KB Output is correct
8 Correct 0 ms 2364 KB Output is correct
9 Correct 0 ms 2364 KB Output is correct
10 Correct 0 ms 2364 KB Output is correct
11 Correct 0 ms 2364 KB Output is correct
12 Correct 0 ms 2364 KB Output is correct
13 Correct 0 ms 2364 KB Output is correct
14 Correct 0 ms 2364 KB Output is correct
15 Correct 0 ms 2364 KB Output is correct
16 Correct 0 ms 2364 KB Output is correct
17 Correct 0 ms 2364 KB Output is correct
18 Correct 0 ms 2364 KB Output is correct
19 Correct 0 ms 2364 KB Output is correct
20 Correct 0 ms 2364 KB Output is correct
21 Correct 0 ms 2364 KB Output is correct
22 Correct 0 ms 2364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2364 KB Output is correct
2 Correct 0 ms 2364 KB Output is correct
3 Correct 0 ms 2364 KB Output is correct
4 Correct 0 ms 2364 KB Output is correct
5 Correct 0 ms 2364 KB Output is correct
6 Correct 0 ms 2364 KB Output is correct
7 Correct 0 ms 2364 KB Output is correct
8 Correct 0 ms 2364 KB Output is correct
9 Correct 0 ms 2364 KB Output is correct
10 Correct 0 ms 2364 KB Output is correct
11 Correct 0 ms 2364 KB Output is correct
12 Correct 0 ms 2364 KB Output is correct
13 Correct 0 ms 2364 KB Output is correct
14 Correct 0 ms 2364 KB Output is correct
15 Correct 0 ms 2364 KB Output is correct
16 Correct 0 ms 2364 KB Output is correct
17 Correct 0 ms 2364 KB Output is correct
18 Correct 0 ms 2364 KB Output is correct
19 Correct 0 ms 2364 KB Output is correct
20 Correct 0 ms 2364 KB Output is correct
21 Correct 0 ms 2364 KB Output is correct
22 Correct 0 ms 2364 KB Output is correct
23 Correct 0 ms 2364 KB Output is correct
24 Correct 0 ms 2364 KB Output is correct
25 Correct 0 ms 2364 KB Output is correct
26 Correct 0 ms 2364 KB Output is correct
27 Correct 0 ms 2364 KB Output is correct
28 Correct 0 ms 2364 KB Output is correct
29 Correct 0 ms 2364 KB Output is correct
30 Correct 0 ms 2364 KB Output is correct
31 Correct 0 ms 2364 KB Output is correct
32 Correct 0 ms 2364 KB Output is correct
33 Correct 0 ms 2364 KB Output is correct
34 Correct 0 ms 2364 KB Output is correct
35 Correct 0 ms 2364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2364 KB Output is correct
2 Correct 0 ms 2364 KB Output is correct
3 Correct 0 ms 2364 KB Output is correct
4 Correct 0 ms 2364 KB Output is correct
5 Correct 0 ms 2364 KB Output is correct
6 Correct 0 ms 2364 KB Output is correct
7 Correct 0 ms 2364 KB Output is correct
8 Correct 0 ms 2364 KB Output is correct
9 Correct 0 ms 2364 KB Output is correct
10 Correct 0 ms 2364 KB Output is correct
11 Correct 0 ms 2364 KB Output is correct
12 Correct 0 ms 2364 KB Output is correct
13 Correct 0 ms 2364 KB Output is correct
14 Correct 0 ms 2364 KB Output is correct
15 Correct 0 ms 2364 KB Output is correct
16 Correct 0 ms 2364 KB Output is correct
17 Correct 0 ms 2364 KB Output is correct
18 Correct 0 ms 2364 KB Output is correct
19 Correct 0 ms 2364 KB Output is correct
20 Correct 0 ms 2364 KB Output is correct
21 Correct 0 ms 2364 KB Output is correct
22 Correct 0 ms 2364 KB Output is correct
23 Correct 0 ms 2364 KB Output is correct
24 Correct 0 ms 2364 KB Output is correct
25 Correct 0 ms 2364 KB Output is correct
26 Correct 0 ms 2364 KB Output is correct
27 Correct 0 ms 2364 KB Output is correct
28 Correct 0 ms 2364 KB Output is correct
29 Correct 0 ms 2364 KB Output is correct
30 Correct 0 ms 2364 KB Output is correct
31 Correct 0 ms 2364 KB Output is correct
32 Correct 0 ms 2364 KB Output is correct
33 Correct 0 ms 2364 KB Output is correct
34 Correct 0 ms 2364 KB Output is correct
35 Correct 0 ms 2364 KB Output is correct
36 Runtime error 0 ms 2368 KB Execution killed because of forbidden syscall gettid (186)
37 Halted 0 ms 0 KB -