Общий форумПочему не проходит тест? Вроде все правильно WA in Case #6. Could you give me the case? Edited by author 11.10.2015 17:59 Edited by author 11.10.2015 17:44 Just print: 1)2*n-1 2)1 2 ... n 3)n n-1 ... 2 It's work, but why? example 4 1 2 3 4 4 3 2 original 4->3->2->1->2->3->4 They don't meet They meet at the 6th point(3 = 3). Why do you need to print that 1 at the beginning? You don't need it. 2 3 4 4 3 2 also works fine. But 3 2 1 3 2 (or 2 3 4 2 3) is shorter. Please help me, what is wrong with my solution.... Const MaxN = 100000; Var b : array[1..MaxN] of boolean; c : array[1..2,1..MaxN] of longint; c_num,n,m,i,x,y : longint; BEGIN Readln(n,m); Fillchar(b,sizeof(b),true); Fillchar(c,sizeof(c),0); c_num := 0; For i := 1 to m do begin Read(x,y); if b[x] and b[y] then Begin Inc(c_num); c[1][c_num] := x; c[2][c_num] := y; b[x] := false; b[y] := false; End; End; Writeln(c_num); For i := 1 to C_num do Begin Writeln(c[1][i],' ',c[2][i]); End; END. Try such test... :) 4 3 2 3 1 2 3 4 Correct answer is 2 1 2 3 4 I don't think, that greedy is a good idea... Try this one 4 3 1 2 1 3 3 4 Correct Answer: 2 1 2 3 4 Кто решил,напишите пару тестов. import sys def wall_scaner(amount, wall): count = 0 high = 0 mid_number = '' while count < int(amount) - 2: summ = 0 unit = wall[count:count + 3] for i in unit: summ += int(i) if summ > high: high = summ mid_number = count + 2 count += 1 return high, mid_number data1 = sys.stdin.readline() data2 = sys.stdin.readline() amount = ''.join(data1.split()) wall = ''.join(data2.split()) answer = wall_scaner(amount, wall) print(answer[0], answer[1]) plz tell me what's wrong this code always return right format and answer for me ты считаешь тройки одинаковых рядом цифр, а по заданию это не нужно. Нужно найти суммарный максимум из рядом стоящих не обязательно это будут 777 может и 845 n = int(input()) sp = list(map(int, (input().split()))) ind = 0 MAX = sum(sp[:2]) for i in range(n - 2): if sum(sp[i:i+3]) > MAX: MAX = sum(sp[i:i+3]) ind = sp.index(sp[i]) + 2 print(MAX, ind) Edited by author 08.10.2015 18:07 What's wrong? Please, answer me. #include <iostream> #include <vector> using namespace std; int main() { bool z; vector <int> so(0), st(0); unsigned int a; cin >> a; while (so.size() < a) { int soe; cin >> soe; so.push_back(soe); } unsigned int b; cin >> b; while (st.size() < b) { int ste; cin >> ste; st.push_back(ste); } for (unsigned int i = 0; i < so.size(); i++) for (unsigned int j = 0; j < st.size(); j++) { if (so[i] + st[j] == 10000) { z = true; } } if (z == true) { cout << "YES" << endl; } else { cout << "NO" << endl; } } Edited by author 24.10.2015 04:23 New test was added, 1158 AC solutions failed. Hi there, My AC code (and, I think, many others) outputs "-1" for the following test, whereas according to the problem statement right answer is "3": 1 5 +-+-+-+.+-+ | | .1|2| | +-+.+-+-+-+ It seems this problem needs more good tests. Up Edited by author 16.01.2013 18:30 Up If you have more good tests, send them to timus_support@acm.timus.ru Do you check this mailbox? Some time ago I sent new tests for 1005 to kill greedy sols - and no reaction on timus side. If you really need new tests for this problem and will add them - I can prepare. Some time ago limitations have been modified to 2 <= n, m (was 1 <= n, m). Sorry for misinformation. I think the problem could be more interesting and challenging with old limitations and new tests. Currently it is rather straightforward. It should be "Death" for your test case as they need to "always" stay close together. Even when one of them is out. You're wrong. According to the problem statement they need to stay close to each other only in order to keep moving. Here it is possible for both of them to leave the labyrinth. > You're wrong. According to the problem statement they need to stay close to each other only in order to keep moving. Your interpretation is not supported by the problem language. I agree with tvhong, the problem statement clearly says that they must stay close. If your interpretation was correct then the second sample would not be "Death." I thought ranking was determined first by solution time, with ties broken by submission date. But you can see here: http://acm.timus.ru/rating.aspx?space=1&num=1797 that the #1 ranked solution has the same solution time as the other top submissions, but a later submission date. Why is this? There are too many different cases to consider, use a brute-force approach to get AC on the first attempt with one page of code: 1) write a function that checks that the situation is good; 2) for every coordinate make a list of four interesting values (all values taken by existing potatoes and some others if this is not enough); 3) try all possible ways to move none, one, or two potatoes, so that the coordinates of the new position are from the interesting values. Disagree. There're only 7 cases to consider. from random import randint v1 = '' v2 = '' cod1 = ''.join(map(str, [randint(0, 9) for _ in range(1, 5)])) cod2 = ''.join(map(str, [randint(0, 9) for _ in range(1, 5)])) while v1 != cod1 and v2 !=cod2: n = input().split() v1 = n[0] v2 = n[1] if v1 != cod1 and v2 != cod2: print('no') print('yes') Tested with already palindrome (as said before), any ideas? For input: aba it will write: ababa and for: abba -> abbabba Can you give me more tests so i can check my programm? Any input i give him is solved correctly, no matter the size or the number of paranthesis. Please help! //package timus; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Scanner; public class p1793 { public static void main(String[] args) { InputStream is = System.in; Scanner sc = new Scanner(new InputStreamReader(is)); double a,b,h,r1,r2,R1,R2,H,rr1,rr2,x1,y1,x2,y2,D,d; boolean inside1,inside2; a = sc.nextInt(); b = sc.nextInt(); h = sc.nextInt(); r1 = sc.nextInt(); R1 = sc.nextInt(); r2 = sc.nextInt(); R2 = sc.nextInt(); H = sc.nextInt(); rr1 = R1; rr2 = R2; if (H >= h) { double d1,d2; d1 = (R1-r1)/2.0; d2 = (R2-r2)/2.0; rr1 = 2*d1 * h / H + r1; rr2 = 2*d2 * h / H + r2; } inside1 = 2.0 * rr1 <= a && 2.0 * rr2 <= b; inside2 = 2.0 * rr1 <= b && 2.0 * rr2 <= a; if (!inside1 || !inside2) { System.out.println("NO"); return; } x1 = rr1; y1 = rr1; x2 = a - rr2; y2 = b - rr2; D = R1 + R2; d = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); if (d >= D * D) { if ((x2 - x1 + rr1 + rr2) <= a && (y2 - y1 + rr1 + rr2) <= b) System.out.println("YES"); else System.out.println("NO"); } else { System.out.println("NO"); } } } With 1 Mb memory limit? :-) AC now:) Edited by author 11.02.2007 15:03 You should store in queue n/2 +1 numbers I can't understand you... How I can do it? At first push n/2+1 numbers then do this 1 read next number 2 push it to queue 3 pop biggest element 4 goto 1 At the end use 2 or 1 top elements for answer Thank you very much!!! I got AC! I use priority queue as you said,but still MLE#7.Maybe I'm wrong,here is my code: #include<iostream> using namespace std; #include<queue> int main() {std::priority_queue<int>pr; int n,i,a; cin>>n; for(i=1;i<=n/2+1;i++) {cin>>a; pr.push(a); } i=n/2+2; while(i<=n){ cin>>a; pr.push(a);i++; pr.pop(); } if(n%2!=0) cout<<pr.top()<<".0"<<endl; else {a=pr.top(); pr.pop(); if(a%2+pr.top()%2==2) cout<<a/2+pr.top()/2+1<<".0"<<endl; else if(a%2+pr.top()%2==0) cout<<a/2+pr.top()/2<<".0"<<endl; else if(a%2+pr.top()%2==1) cout<<(a/2+pr.top()/2)<<".5"<<endl; } return 0; } Thank!!! Edited by author 18.09.2007 19:59 int v[250000/2+3]; for(; i < n/2+1; ++i) cin >> v[i]; make_heap(v,v+n/2+1); for(; i < n; ++i){ cin >> v[n/2+1]; push_heap(v,v+n/2+2); pop_heap(v,v+n/2+2); } BTW(1), there is no need for "unsigned" since input is less than 2^31-1 BTW(2), there is no need to avoid "double a" in calculation and output of the the final answer: cout << setprecision(1) << fixed << a << endl; BTW(1), there is no need for "unsigned" since input is less than 2^31-1 There was an example of possible input in early posts on the forum: [(2^31 - 1) + (2^31 - 1)] / 2 = 2^31 - 1 but ((2^31) - 1) + ((2^31) - 1) = 4 294 967 294 so if you don't know how to manage such a thing you should use unsigned int. BTW there is no differences in allocated memory between "unsigned" and "signed int" but "unsigned" work faster. one way to avoid overflow of calculating ((2^31) - 1) + ((2^31) - 1) is to compute ((2^31-1) * 0.5) + ((2^31-1) * 0.5) instead of ( ((2^31) - 1) + ((2^31) - 1) ) * 0.5 I have learnt a lot ,thanks. I use G++ 4.9 and get MLE. Then I try G++ 4.9 C++ 11 and AC. Why? :( All ok!) Edited by author 03.10.2015 14:49 Edited by author 03.10.2015 14:49 Edited by author 05.10.2015 18:55 |
|