Общий форумhi can you please show / send me some hint about test #2 ? (I think you can see the source code of my attempt) p519446 at yandex.ru TIA. I am learning python. When i see the example of problem 1000 and 1001, python reads from stdin. How can i read from input.txt without changing my program every time i send it in. e.g. pascal uses #ifdef online_judge to read from files In linux I prefer to use this command: xclip -out | python problem.py It takes input from clipboard and send it to script. I use Windows on my computer. When i define a function like def invoer(place): if place=='file': f = open('input.txt', 'r') regel=f.readline() print(sum(int(x) for x in regel.split(' '))) f.close() else: print(sum(int(x) for x in input().split(' '))) invoer('console') I can use a file. Is there a smarter way? hi all I'm interesting on praxis to solve tasks using java threads. Do we have here such ones ? Many thanks to author of this task and Oleg Strekalovsky [Vologda SPU] for the hint ( http://acm.timus.ru/forum/thread.aspx?id=22536&upd=634614144741133716 ). PS. It is very unexpectedly to me that some collection types (e.g. HashMap) take so much memory and CPU time in java :-/ Edited by author 19.04.2013 22:14 Edited by author 19.04.2013 22:14What the hell is test 9? In my computer I got 0.06s in worst case but still TLE 9! Write me 10 test, please ! write test 10 pls I dont know test 10.But I can help you if you give me your algo or code. I have already solved this problem. my email is ibragim.atadjanov@gmail.com First I got WA on test 10.Because my DP solution is wrong: this is AC solution: tt[0].a=tt[0].b=0; for(int i=1;i<=k;i++) { scanf("%d%d",&tt[i].a,&tt[i].b); } sort(tt,tt+k+1,cmp); memset(dp,0,sizeof(dp)); for(int i=1;i<=k;i++) { for(int j=0;j<i;j++) { if(tt[j].a<tt[i].a&&tt[j].b<tt[i].b) { dp[i]=max(dp[j]+1,dp[i]); } } }
this is WA solution for(int i=1;i<=k;i++) { scanf("%d%d",&tt[i].a,&tt[i].b); } sort(tt+1,tt+k+1,cmp); memset(dp,0,sizeof(dp)); dp[1]=1; for(int i=2;i<=k;i++) { for(int j=1;j<i;j++) { if(tt[j].a<tt[i].a&&tt[j].b<tt[i].b) { dp[i]=max(dp[j]+1,dp[i]); } } } sorry for my poor English .hope to help~ I guess there is a test case that the condition 1<=Q<=N-1 is not satisfied. I put a condition that if Q is outside the given interval then output 0 and got WA#1. Without this condition, it gives WA#8. Edited by author 18.04.2013 20:01 My programm works on my computer. Timus gives me this verdict. Why it may be?I write on C++ in Dev. May be I cannot use strings? Edited by author 16.03.2011 20:11 for string you should write #include<string> #include <iostream> #include <map> using namespace std; int main() { map<int,int> table; int x,y,sum = 3; while(sum--) { cin >> x; while(x--) { cin >> y; table[y]++; } } int s = 0; for(int i = 0;i < table.size();i++) if(table[i] == 3) s++; cout << s; return 0; } import java.util.Scanner; public class T_1226_esreveR_redrO { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String set="ABCDEFGHIJKLMNOPQRSTUVXYZWabcdefghijklmnopqrstuvxyzw"; String s =sc.nextLine(); String p=""; for (int i = 0; i < s.length(); i++) { if(set.indexOf(s.charAt(i)+"")>-1) p=s.charAt(i)+p; else{ System.out.print(p); p=""; System.out.print(s.charAt(i)); } } System.out.println(p); } } } public class T_1226 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String l = ""; char c; while (br.ready()) { char s = (char) br.read(); if ((65<=s && 90>=s)||(97<=s && 122>=s)) { l = s + l; } else { System.out.print(l + s); l = ""; } } System.out.print(l); } } My code Accepted!!! Edited by author 17.04.2013 18:28 Time limit is changed from 4 to 2 seconds. First test is changed to the sample. Submissions are rejudged. #include<iostream> #include<queue> #include<stdio.h> using namespace std; int main() { int n,i,k,m,n1,n2; priority_queue<int>a; cin>>n; m=n/2+1; for(i=1;i<=m;i++) { cin>>k; a.push(k); } for(i=m+1;i<=n;i++) { cin>>k; a.push(k); a.pop(); } if (n%2) printf("%.1f",1.0*a.top()); else { n1=a.top(); a.pop(); n2=a.top(); printf("%.1f",((float)n1+(float)n2)/2); } system("pause"); return 0; } 76 85 46 -22 4 15 -10 14 -12 7 -14 20 17 42 11 15 10 -10 60 15 18 -10 43 -51 27 22 -50 -32 -60 -11 -3 -29 -65 -13 -10 2 37 -7 9 -37 -39 42 80 -28 55 -41 -7 -77 -11 17 -6 -54 -55 -48 8 -58 -17 -52 -42 -8 26 -4 24 -13 29 41 -52 14 12 17 55 12 -50 43 27 -8 -33 -78 -42 -2 2 -71 -39 -6 52 -5 -25 62 -51 -2 -19 45 10 12 3 47 -61 37 13 -41 -7 -12 -7 -25 12 15 44 5 -47 -8 -3 -17 -12 -60 -2 28 37 -5 29 -7 -59 61 -17 50 -42 -19 26 51 -10 11 10 5 -1 31 -50 -23 7 -35 29 -47 -5 21 -69 11 13 -17 26 3 13 58 -40 30 -20 -12 please add this test i found many AC program can't pass it.(they use Simulated Annealing) 58 88 40 -15 16 -18 -35 -53 -26 10 10 -64 -19 33 25 48 75 6 12 -65 29 31 -1 57 30 12 27 17 44 -11 24 -2 16 -25 21 -4 -57 24 51 25 26 20 -12 -27 23 -29 -22 6 13 -4 -11 -57 -18 17 -32 -22 -70 -17 -31 22 -47 69 -53 -64 -23 20 33 10 -13 -8 11 -25 -5 68 73 23 49 -15 68 -31 -33 -56 6 36 -13 -51 0 79 55 36 24 -1 54 -13 -21 -16 16 40 -38 11 15 3 20 -2 18 10 -16 27 -41 23 48 -24 35 -39 -61 10 -51 -14 also a good test at last ,sorry for my poor english Strange, string s = Console.ReadLine(); ===>AC string s = Console.ReadLine().Trim(); ===> Runtime Error (AV #2) string s = Console.ReadLine().TrimEnd(); ====> Same as above who can explain this? Console.ReadLine() == null at the end of file thanks... yes. it all makes sense now. wrong answer in test 13, help me! Edited by author 15.04.2013 23:26 What parameters in the test number 9? I found such test: 36 25 12 10 8 7 1 the right answer 1, but I received the response 5 - really the program wrong, the unique decision - search of all possible options! PS: а не по английски тут можно писать? Edited by author 15.04.2013 15:15 What is test 7? here is my code. It is working on the available sample inputs. Please help. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.StringTokenizer; /** * * @author proy */ class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** call this method to initialize reader for InputStream */ static void init(InputStream input) { reader = new BufferedReader(new InputStreamReader(input) ); tokenizer = new StringTokenizer(""); } /** get next word */ static String next() throws IOException { while ( ! tokenizer.hasMoreTokens() ) { //TODO add check for eof if necessary tokenizer = new StringTokenizer(reader.readLine() ); } return tokenizer.nextToken(); } static int nextInt() throws IOException { return Integer.parseInt( next() ); }
static double nextDouble() throws IOException { return Double.parseDouble( next() ); } } public class p1106 {
public static void main(String args[]) throws IOException { int a; Reader.init(System.in);
int n = Reader.nextInt(); int graph[][]= new int[n][n]; ArrayList<ArrayList<Integer>> st = new ArrayList<ArrayList<Integer>>(); ArrayList<Integer> grp1 = new ArrayList<Integer>(); ArrayList<Integer> grp2 = new ArrayList<Integer>(); for (int i = 0; i<n;i++) { ArrayList<Integer> ar = new ArrayList<Integer>(); do { a = Reader.nextInt(); if(a !=0) { graph[i][a-1] = 1; ar.add(a-1); }
} while(a!=0); st.add(ar); }
if(n!=0) { grp1.add(0); for(int i = 1; i<n; i++) { if(graph[0][i]!= 1 ) { grp1.add(i); }
else { grp2.add(i); } }
for(int i = 1; i<grp1.size();i++) { int x = grp1.get(i);
if(!st.get(x).isEmpty()) { boolean frFlag = false; Iterator it = st.get(x).iterator(); while(it.hasNext()) { if(grp2.contains((Integer)it.next())) { frFlag = true; continue; } }
if(!frFlag) { Integer rm = st.get(x).get(0); //grp1.r grp1.remove(rm); grp2.add(rm); } }
}
System.out.println(grp1.size()); Iterator it1 = grp1.iterator(); while(it1.hasNext()) { System.out.print(((Integer)it1.next()+1)+ " "); } }
else { System.out.println(0); }
}
} Подскажите какой пример в 10ом тесте? уперся и ничего не могу поделать. За ранее спасибо Попробуй отладить этот код, мне помогло найти ошибки //string[] source = { "62", "45", "73", "roygbv" }; //string[] ex1 = { "9", "73", "45", "..bvgy" }; //string[] ex2 = { "73", "45", "12", "bvyg.." }; //string[] ex3 = { "45", "7", "73", "gyo.vb" }; //string[] ex4 = { "73", "45", "12", "bvyg.." }; //string[] ex5 = { "73", "4", "45", "bv..gy" }; //string[] ex6 = { "45", "1", "73", "yg.rbv" }; //string[] ex7 = { "73", "1", "45", "vb..gy" }; //string[] ex8 = { "16", "45", "73", "..ygbv" }; Edited by author 13.04.2013 20:53 тут все верно строит, без ошибок Не ахти какая помощь, но все ж 1 - 2 тесты - один целый куб 3 - 4 тесты - два куска 5 - 15 тесты - три куска 16 - 18 тесты - кусков больше трех, точно не знаю сколько. С третьего по 18 тесты включительно разрезание в одной плоскости @r0me: аналогично, без ошибок (ну разве что ответ я не проверял)... я и ответ проверил и в других плоскостях все проверил, и уже почти все что можно вводил, ошибку не выявил( интересно, что же я упустил... Если я правильно понимаю, до 19ого теста в кусочке может быть максимум две точки, для тех что посредине и одна , для тех что по краям? Edited by author 15.04.2013 11:32 А изменение координат идет только по одной оси, то есть в ответе будет 0 0 7- координаты для кусочка, за исключением первого. Так оно? hi I found some hint about this task (PQ usage with size = n/2+1) and applied it. My class have only PQ<Integer> object and three int variables + StreamTokenizer + System.out. Unfortunately, I've got MLE (1096 Kb). So I think that java needs more than 1 Mb to store 125'001 elements on PQ<Integer> - is it right ? If yes than which way this task can be solved using java ? TIA. |
|