|
|
Try this test: 2 3 -1 Answer: 1 3 3 Since k <= 10 and |ai| ≤ 1000 the largest answer is 10001: let use -11000..11000 to be sure. Since the end of each segment is an integer such that on one side inequality holds and on the other it is not, the solution is trivial: just find all such points. Still the following program gives WA4. Any hint? #define I(x) int x; cin >> x #define FA(i,c) for(auto& i: c) #define FE(i,a,b) for(int i = (a); i <= (b); ++i) typedef vector<int> V; V a; bool in(double x){ FA(ai,a) x = fabs(x-ai); return x < 1; } int main(){ I(k); a.resize(k); FA(ai,a) cin >> ai; V b; FE(ix,-11000,11000) if(in(ix-0.1) != in(ix+0.1)) b.push_back(ix); cout << b.size()/2 << endl; for(size_t i = 0; i < b.size(); i += 2) cout << b[i] << ' ' << b[i+1] << endl; } < https://en.wikipedia.org/wiki/Line_segment>:a line segment is a part of a line that is bounded by two distinct end points In this problem, the end points of a "segment" are not required to be distinct (first occurrence in test 4). Input: 2 1 1 Output 1: 1 -1 3 Output 2: 2 -1 1 1 3 Какой из ответов правильный? Edited by author 01.02.2013 09:18 if you get WA 4 and you solve the problem from the end, than (maybe) you must take into account that sensor return only possitive number or null ans intermediate value can be >= 0. Edited by author 15.10.2012 02:29 Edited by author 14.10.2012 00:59 сам ни до конца понял я условие понял, но ва6. Edited by author 14.10.2012 00:59 числа из отрезка подходят под нормальный сигнал! Edited by author 14.10.2012 00:59 |
|
|