Common BoardI`m sure that written algo is correct, but I might make stupid mistake... My solutions can pass all my tests and my friends` also. Please, give me some tricky tests! Thanks a lot! 2 2 0 1 2 0 * 2 1 1 0 2 3 0 answer 5 Here are some tests: TEST : 10 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 * 1 1 10 0 answer 100 TEST: 1 3 1 10 0 2 -5 0 3 -1000 0 answer -1000 Here are some tests: TEST: 1 3 1 10 0 2 -5 0 3 -1000 0 answer -1000 I think this test is wrong, because we have only 1 planet on the 0th level, So it should be: 1 3 1 10 0 1 -5 0 1 -1000 0 I keep getting non-zero return from WA #9 (meaning some of my scanf() fails) Could you please forward WA #9 problem so that I can check parsing is proper? Thank you, Test #9 probably contains upper limit case, when there are max possible levels with max planets in each, I can suggest you to check your array sizes. I also got WA #9 after setting wrong integer value for "unreachable" planets - I've set it too small and it affected the result at this test You're right... After changing the values to a higher value for the unreachable nodes, I got AC. Thanks. import java.io.*; import java.util.*; public class task { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int t; if(n>=1 && k<=1000) { if((int) (n * 2.0 / k) == (n * 2.0 / k)) t = (int) (n * 2.0 / k); else t = 1 + (int) (n * 2.0 / k); out.print(t);
} out.flush(); } } Братан эту задачку на 1 вывод решить можно) зачем тебе эти условия Edited by author 29.10.2015 01:41 Я одного не пойму, как можно обжарить 3 бифа с обеих сторон за 3 минуты, если влазит на сковороду всего 2 шт???))) На первой минуте жаришь первые 2шт с одной стороны, на второй их же со второй. На третей минуте последний биф 1 сторона 4я минута 2я сторона 3го бифа!!. В итоге правильный ответ 4 минуты, а не 3 как написано в примерах. Изи. Смотри 1 и 2 это первые и вторые стороны бифов. B это номер бифа. Разделю их точкой первая минута: 1.1 1.2 вторая минута: 2.1 1.3 третья минута: 2.2 2.3 Я тоже также думал, пока не прочитал в дискуссии: http://acm.timus.ru/forum/thread.aspx?id=36182&upd=636324641214598077 1-я минута - Жарится одна сторона двух стейков.(1-я сторона) 2-я минута - Жарится один из первых стейков(2-я сторона) + третий стейк(1-я сторона) 3-я минута - Жарится второй из первых стейков(2-я сторона) + третий стейк(2-я сторона) #include <iostream> #include <stdio.h> #include <vector> using namespace std; class Place { public: char x; int y; bool isOnboard() { if (x < 'a' || x > 'h' || y < 1 || y > 8) return false; return true; } Place(char x, int y) { this->x = x; this->y = y; } }; int main(int argc, const char * argv[]) { int N; cin >> N; vector<Place> places; for (int i = 0; i < N; i++) { char x; int y; cin.get(x); if (x == '\n') { i--; continue; } cin >> y; Place place (x, y); places.push_back(place); } for (int i = 0; i < N; i++) { Place place = places[i]; int moves = 0; //left 2 up 1 place.x -= 2; place.y -= 1; moves += place.isOnboard(); //left 2 down 1 place.y += 2; moves += place.isOnboard(); //right 2 down 1 place.x += 4; moves += place.isOnboard(); //right 2 up 1 place.y -= 2; moves += place.isOnboard(); //right 1 up 2 place.x -= 1; place.y -= 1; moves += place.isOnboard(); //left 1 up 2 place.x -= 2; moves += place.isOnboard(); //left 1 down 2 place.y += 4; moves += place.isOnboard(); //right 1 down 2 place.x += 2; moves += place.isOnboard(); cout << moves << endl; } } I get, Runtime error (non-zero exit code), even if I send a program such: fn main() { println!("{}",-1); } If I paste the solution, in the submission text box, I am able to get an answer from the judge. If I uploaded I always get "Runtime error (non-zero exit code)" Когда использую циклы такого вида выдает ошибку Runtime error (non-zero exit code) i=n; while(i>0) { name[i]=calloc(1,30); scanf(" %s",name[i]); i--; } i=n; while(i>0) { char *buf=name[i]; while(*buf!='\0') { if(*buf=='+') { kol++; break; } else { buf++; } } i--; } А здесь AC for(i=0;i<n;i++) { name[i]=calloc(1,30); scanf(" %s",name[i]); } for(i=0;i<n;i++) { char *buf=name[i]; while(*buf!='\0') { if(*buf=='+') { kol++; break; } else { buf++; } } } try 6 6 0 3 0 5 0 5 6 0 0 0 and 7 2 0 5 0 6 4 0 5 7 0 0 0 0 Well, I've passed that tests, but still getting WA 13 Any advices? When build the graph, make it undirected rather than directed one. import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Lesson { public static void main(String[] args) throws Exception { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int countPrepod = Integer.parseInt(bufferedReader.readLine()); TreeSet<Long> prepod = new TreeSet(); for (int i = 0; i < countPrepod; ++i) { prepod.add(Long.parseLong(bufferedReader.readLine())); } int countStudent = Integer.parseInt(bufferedReader.readLine()); ArrayList<Long> student = new ArrayList(); for (int i = 0; i < countStudent; ++i) { student.add(Long.parseLong(bufferedReader.readLine())); } student.sort(((o1, o2) -> Long.compare(o1,o2))); int result=0; for (long find:prepod) { while (Collections.binarySearch(student,find)>=0) { ++result; student.remove(find); } } System.out.println(result); } } 1. This problem can be reduced to the following: Given X, find two vertices such that path weight is equal to X. 2. It probably cannot be solved with naiive DP. Use centroid decomposition. 3. std::unordered_map gets TL while std::map gets AC. i have some problems with (), please give answers for some other cases 1 Edited by author 06.11.2015 00:47 Input: 4 Output: (((sin(1)+4)sin(1-sin(2))+3)sin(1-sin(2+sin(3)))+2)sin(1-sin(2+sin(3-sin(4))))+1 What it is it? My program overcome all my tests,but system(TIMUS) written me about WA#9! WHY? me too! any ideas, please send to: williamm2006@126.com thanks! program p1406; var a:array[1..2000]of longint; ch:char; i,j,k,n,m:longint; begin while not eof(input) do begin read(ch); if ch in['0'..'9'] then begin inc(n); a[n]:=ord(ch)-48; end; end; for i:=n downto 1 do if a[i]>0 then break; if((i=1)and(a[i]=0))or(n=1) then begin writeln(-1); halt; end; j:=i-1;m:=a[i]-1;a[i]:=0; for j:=i-1 downto 1 do if a[j]<>9 then break; if(j=1)and(a[j]=9) then begin writeln(-1); halt; end; inc(a[j]); for i:=j+1 to n do begin inc(m,a[i]); a[i]:=0; end; i:=n; while m>0 do begin if m>=9 then a[i]:=9 else a[i]:=m; dec(i); dec(m,9); end; for i:=1 to n do write(a[i]); writeln; end. Don't be afraid of geometry, this problem is really easy Please, fix English in the statement: is maked -> is made You standing -> You're standing you have made -> you made Thank you! Is it supposed to be solved without floating-point numbers at all? This problem is definitely can be solved using integers only Don't be afraid of geometry, this problem is really easy I confirm :) #include<iostream> using namespace std; int sum(int temp); int main(){ int a[6]; scanf("%1d%1d%1d%1d%1d%1d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); int first=a[0]*100+a[1]*10+a[2]; int second=a[3]*100+a[4]*10+a[5]; if(a[3]==9&&a[4]==9&&a[5]==9){ cout<<"No"; return 0; } int pre=second-1; int next=second+1; if((sum(pre)==(a[0]+a[1]+a[2]))||(sum(next)==(a[0]+a[1]+a[2]))){ cout<<"Yes"; }else{ cout<<"No"; }
return 0; } int sum(int temp){ int count=0; do{ count+=(temp%10); temp/=10; }while(temp/10!=0); count+=temp; return count; } #include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; class team{ public: string id; int n; }; bool comp(const team &t1,const team &t2); int main(){ int k; cin>>k; vector<team> T; while(k--){ string temp; int num; cin>>temp>>num; team t; t.id=temp; t.n=num; T.push_back(t); } stable_sort(T.begin(),T.end(),comp); for(int i=0;i<T.size();++i){ cout<<T[i].id<<" "<<T[i].n<<endl; }
return 0; } bool comp(const team &t1,const team &t2){ return t1.n>t2.n; } Why Wring answer? import java.util.Scanner; public class T1654 { public static char[] arr; public static String out = ""; public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String inp = sc.next(); sc.close(); arr = new char[inp.length()]; arr = inp.toCharArray(); format(); if(out != "") { System.out.println(out); } else { System.out.println(""); }
}
public static void format() { boolean isFormat = false; int l = arr.length; for(int i = 0; i< l-1; i++) { if(arr[i] == arr[i+1]) { arr[i] = 0; arr[i+1] = 0; isFormat = true; } else if(arr[i] != arr[i+1] & arr[i] != 0){ out += arr[i]; } } out+= arr[arr.length-1]; if(isFormat == true) { arr = new char[out.length()]; arr = out.toCharArray(); out = ""; format(); } } } получил АС, долго искал где долбанный баг, т.к. ТЕСТ 22 выдавал ошибку по времени, если у вас такая же проблема и вы используете преобразование double в int то в 22 тесте точность P и Q 3 знака, поэтому ТЛ и выдает, вероятно на вход подаются какие нибудь числа 22.333 и 22.334 удачи You are wrong! P and Q are given with up to 2 digits after decimal point in all tests. похожая фигня, точности 2 знаков после запятой не хватало, впилил третий знак, всё заработало code like: size_t out = 0; printf ("%zu\n", out); result - > wa#1 ((( if i use printf ("%d\n", out); all test accepted (( Why? https://wandbox.org/ & gcc 7.1 - The first version works correctly ((( i have ac in 0.187 s, but on this test my program runs at least 0.9: 35 123 2 3 4 5 6 0 8 9 10 11 0 13 14 15 0 17 18 0 20 21 0 23 0 25 0 27 0 0 0 0 0 0 0 0 0 |
|