| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Solution | Denis Rozimovschii | 1987. Вложенные отрезки | 29 мар 2018 23:24 | 3 |
Solution Denis Rozimovschii 14 авг 2015 22:02 One of the solutions would involve sorting and stacks. I've tried to use reb-black tree, but it seems to have problems with dublicate-keys. Edited by author 14.08.2015 22:05 I got AC by iterating all the ranges and putting them in a stack. Basically, if next range fits into previous one, put it in a stack. If it does not, remove previous ranges from the stack until it does (or the stack gets empty). At each step, update the answers to relevant queries. Binary search is good enough for finding them. it's possible to solve this problem with segment tree. Just put all answers into segment tree with meaning -1 and then update it with segments, sorted by range |
| Interesting problem | __Andrewy__ | 1481. Шансы на победу | 29 мар 2018 22:44 | 1 |
HINT1: solution always exist HINT2: try to solve this problem with end. HINT3: this problem can solve <= O(n logn) |
| How do we have a stable sort better than the builtin timsort in Python? | kitchent | 1100. Таблица результатов | 29 мар 2018 15:01 | 1 |
I tried implementing mergesort which probably had recursion depth runtime error; bisect insertion to save some memory, but too slow for python list (perhaps a good alternative if I have access to pointer?); heapq is much faster but instable. What are other options? |
| I CAN´T SEE WHAT IS WRONG (JAVA ) | Felix Leonel Chaves | 1001. Обратный корень | 29 мар 2018 01:27 | 2 |
import java.io.InputStreamReader; import java.text.DecimalFormat; import java.util.Scanner; public class Reverse { private static void printer(double value){ String pattern = "###0.0000"; DecimalFormat myFormatter = new DecimalFormat(pattern); String output = myFormatter.format(value); System.out.println(output); } public static void main(String[] args) { Scanner sc = new Scanner(new InputStreamReader(System.in)); long a,b,c,d; a = sc.nextLong(); b = sc.nextLong(); c = sc.nextLong(); d = sc.nextLong(); printer(Math.sqrt(d)); printer(Math.sqrt(c)); printer(Math.sqrt(b)); printer(Math.sqrt(a)); } } In your solution, it is possible just 4 numbers (a,b,c,d). Suggestion: try using a loop instead of a,b,c,d and finish the loop when the user type something different than a number |
| It's very easy problem | [BSU] nzamulov | 1336. Проблема Бен Бецалеля | 28 мар 2018 04:43 | 6 |
It's very easy problem, but many people don't understand how to solve it ... :) 7 lines : #include <iostream> using namespace std; int main(){ unsigned long long N; cin >> N; cout << N*N << endl << N; return 0; } 5 lines: #include <iostream> void main() { unsigned long long N; std::cin >> N; std::cout << N*N << std::endl << N; } 4 lines: public class solver { public static void main(String[] args) { long n = new java.util.Scanner(System.in).nextInt(); System.out.println(n*n + "\n"+n);}} var n:int64; begin read(n); writeln(n*n); write(n) end. Edited by author 06.10.2014 22:49 OMG, i made prime factorization of n, searching for odd powers, multiplying to get k got AC, but now I see it was not neccassary Also for 18 i got 12 and 2, as in example. Edited by author 27.11.2015 02:00 1 line, no ";" tricks to put multiple lines into one :) print (lambda x : str(int(x) * int(x)) + '\n' + x)(raw_input()) |
| Who knows test 6? | Михаил | 1966. Велодорожки | 27 мар 2018 16:10 | 1 |
|
| WA#1 | Yerlan | 1029. Министерство | 26 мар 2018 21:49 | 1 |
WA#1 Yerlan 26 мар 2018 21:49 My code fails with WA#1 although it passes every test cases that I've found in comments. Any hints? |
| I don't understand the statement | mouse_wireless2 | 1059. Выражение | 26 мар 2018 11:13 | 1 |
Why isn't the output for 1 just: 1 ? It is equivalent to: 0 X * 1 + ... but it is shorter. The problem asks for minimal length doesn't it? |
| Anyone has Test #7? | kitchent | 1002. Телефонные номера | 26 мар 2018 02:39 | 1 |
Problem solved. Was using a greedy solution which omitted some of the possibilities. Edited by author 26.03.2018 11:18 |
| Ввод данных без перехода на новую строку. | Ragen | 1030. Титаник | 24 мар 2018 20:50 | 2 |
Всем привет. Пишу на с++. И возникла проблема с вводом широты и долготы без перехода на новую строку. Выходит: <X1> ^<X2> '... что не очень красиво. Хотелось бы так <X1>^<X2>'<X3>" <NL/SL> но не знаю как реализовать. Спасибо. scanf("%d^%d'%d\" %cL", &x1, &x2, &x3, &ch); |
| my submission list? | Faysal Ahmed | | 23 мар 2018 18:23 | 2 |
how can i see my submission list? Edited by author 23.03.2018 17:43 Edited by author 23.03.2018 17:43 |
| any information about test 13 ? | SerjMakarov | 2014. Женя переезжает от родителей | 23 мар 2018 06:46 | 1 |
|
| 9th test | Shohin | 2011. Длинное условие | 21 мар 2018 07:12 | 3 |
test 2 1 1 1 1 1 1 ans: Yes |
| Time limit exceeded on tes 8 (java), i dont know which way is excellent | Aydar1 | 1654. Шифровка | 21 мар 2018 06:11 | 4 |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.Stack; public class problem1654 { public static void main(String[] args) throws IOException { BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); String str=inp.readLine(); Stack<Character> st=new Stack<Character>(); st.push(str.charAt(0)); String s=""; for(int i=1;i<str.length();i++){ if(!st.empty()&&st.peek()==str.charAt(i)) st.pop(); else{ st.push(str.charAt(i));
} }
while(!st.empty()){ s=s+st.pop(); } int n=s.length(); for(int i=0;i<n;i++){ System.out.print(s.charAt(n-i-1));
} }} When i used stack(from STL) in C++, i'd got TL8. But after i realzed stack by using array, i got AC your reply help me very much!3Q Don't use : while(!st.empty()){ s=s+st.pop(); } -------- Use this phrase at the end of your Code: Iterator<Character> b = st.iterator(); while(b.hasNext()){ System.out.print(b.next()); } |
| Incorrect unswer. Unknown | Ayrat | 1002. Телефонные номера | 20 мар 2018 19:07 | 1 |
Here is my code and here is my output. Everything should work! What's wrong ? What requirements have I not fulfilled? http://lpaste.net/13924843521971322887325189087 5 it your reality real our reality our 4294967296 5 it your reality real our No solution. -1 The code is written in pure C. The compiler is gcc |
| hints | ASK | 1234. Bricks | 20 мар 2018 16:02 | 1 |
hints ASK 20 мар 2018 16:02 for all-integer comparison you have to use int64_t do not derive the inequality by hand, use Maxima: rot(c,s) := matrix([c,-s],[s,c]); /* D: sqrt(a^2+b^2); */ ma: rot(e/D, sqrt(D^2-e^2)/D); mb: rot(b/D, a/D); dd: (ma.mb.[a,-b])[1][1],ratsimp; load(ineq)$ assume(D>0)$ assume(a>0)$ assume(b>0)$ assume(d>0)$ assume(e>0)$ ne: d >= dd; ne: (ne * D^2)-2*a*b*e,ratsimp; |
| what went wrong here? I compiled it in dr.Java and it was okay | Riyad Ahsan Auntor | 1068. Сумма | 20 мар 2018 04:51 | 4 |
import java.util.Scanner; public class Sum{ public static void main(String args[]){ Scanner sc= new Scanner(System.in); int N, sum=0; System.out.print("Enter the value of N:"); N= sc.nextInt(); if(N<10000){ if(N<0){ for(int x=N; x<=1; x++){ sum+=x; } } else{ for(int x=1; x<=N; x++){ sum+=x; } } } System.out.println(sum); } } System.out.print("Enter the value of N:"); comment this out, automatic checker doesn't know that this text isn't the part of your answer yup did that too and it still says wrong answer Okaaaaay... if(N<10000){ i assume you wanted to check here if input data is correct, but there's no need to do that, input data is correct by default. Not to mention that you do it wrong, you check if N is between (-infinity; 9999], while N should be between [-10000; 10000]. Also i think you don't handle the N=0 case correctly, but hopefully you'll figure out why without more hints. |
| No subject | Slabikov | 1068. Сумма | 19 мар 2018 23:50 | 1 |
Edited by author 20.03.2018 00:35 |
| An efficient solution | Gilles Deleuze | 1223. Chernobyl’ Eagle on a Roof | 19 мар 2018 20:39 | 1 |
Define d[i][j] to be the maximum number of floors that can be checked with i eggs after j steps. To answer the query one should do the binary search to find number of steps X such that d[input_eggs][X] >= input_floors with X being smallest possible. d[i][i] = i, d[2][5] = 15 ,d[2][6] = 21 ( 1 -> 6 -> 11 -> 15 -> 18 -> 20 -> 21 ) d[i][j] = d[i - 1][j] + d[i - 1][j - 1] + 1; Explanation of the formula: Suppose we know d[i][j - 1] and d[i - 1][j - 1] Throw an egg from (d[i - 1][j - 1] + 1) floor. Did it break? If yes, we can definitely check all floors from the first to d[i - 1][j - 1]th with remaining i - 1 eggs within remaining j - 1 steps. If it didn't then you just check how many floors you can check at most with i eggs within j - 1 steps starting from ((d[i - 1][j - 1] + 1) + 1) th floor d[i][j] can be calculated in N^2 Query is answered in log(N) time My Java 1.8 solution runs in 0.062s. Edited by author 19.03.2018 20:45 |
| Comp error | nexerd | 1119. Метро | 19 мар 2018 16:47 | 2 |
while (n>0) { b=a; b=b/pow(10,n-1) - rezult/pow(10,n-1); for (int i=1;i<10;i++) if ((b-i>=0)&(b-i-1<0)) rezult += (i)*pow(10,n-1); n--; } /* if delete : b=b/pow(10,n-1) - rezult/pow(10,n-1); for (int i=1;i<10;i++) if ((b-i>=0)&(b-i-1<0)) rezult += (i)*pow(10,n-1); - work! */ 1. Which programming language do you use? 2. Did you name the variable for result "rezult" (if there is need to pre-declare variables in yout PL)? |