|
|
Common BoardWhy 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 I've got accepted after adding the condition of end of file in creating new line. May be, it will be useful. Edited by author 31.01.2016 15:50 Edited by author 31.01.2016 15:50 2 5 11 as fg asdf asdfr a qwer as s s qwer e Correct answer is 5 #include<iostream> #include<vector> #include<algorithm> using namespace std; int main(){ int k; cin>>k; vector<int> line1; vector<int> line2; vector<int> sum; while(k--){ int m,n; cin>>m>>n; line1.push_back(m); line2.push_back(n); } bool plus_1=false; for(int i=line1.size()-1;i>=0;i--){ int temp=line1[i]+line2[i]; if(plus_1){ temp++; } if(temp>=10){ plus_1=true; temp-=10; }else{ plus_1=false; } sum.push_back(temp);
} for(vector<int>::reverse_iterator iter=sum.rbegin();iter!=sum.rend();++iter){ cout<<*iter; } return 0; } I've been wa on this case for a long time: abaabaaba The right answer is abaabaabaaba Can anyone please suggest the test case which might give me WA35... I have used string , also tried with character array... and KMP algorithm ..... please do reply Edited by author 27.08.2018 13:31 Aren't 'abaabaaba' a palindrome? Can anybody please give me cases for Test2 ? If you only go through the matrix and saved the minimum value, it is not the solution for that problem. Really fast. for (int k = 0; k < n; ++k) { for (int i = graph[k]._Find_first(); i < n; i = graph[k]._Find_next(i)) { graph[k] |= graph[i]; } } I created array p[1..10000000] of boolean; p[i]=true when exist i in input. But i can t prove that if length of input <=100000 then absent numb <=10000000 because if you will write all numbers from 1 to 10000000. string length will be more than 10^5 Edited by author 11.02.2019 20:58 All compilers are succeed with this code. What's wrong? #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { double buffer[128*1024]; unsigned long long number, n=0; while(cin >> number) { buffer[n]=pow(number,1.0/2.0); n++; } for (int i=n-1;i>=0;i--) { cout << fixed << setprecision(4) << buffer[i] << endl; } return 0; } So for this test: 0 0 90 5 0 -0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 correct answer is 31.4159, right? Edited by author 01.02.2019 23:40 It's very funny to read how I tried to solve: 1-st time I forgot to multiply answer by 2 :) 2-nd time I retyped code by forgot to set 'Pascal' (and it was compile error) 3-rd time I forgot 'begin' :) 4-th time I typed task correctly and it was accepted !!! So, programmers, DO NOT HURRY if you don't want to repeat my funny story :) Edited by author 10.09.2004 00:28 In Poland there is a proverb - "Pospiech jest zlym doradca" - "Hurry is a bad adviser" ;) In Russia we say: "Pospeshish - ludey nasmeshish" - "Making it harry you make people laugh at you". It happens simetimes with everyone. Specially, when current cotest is quite durty-solvable... Don't WORRY :).We forgot READLN in another problem... Do you have solution to problem#1407 Did you show a results of input? N=5; A=2; B=3; Answer should be 30 nanokg; i have read 60 kg. What is it?
the panels need processing of both sides. In Thailand, we say : "Slower, a better knife" Problem Election, my submission are 3 times because of the same story as you !! [ 1st - I forgot to print '%' after floating point ] [ 2nd - I put '%' but forgot to print '\n' ] [ 3rd - It was ACCEPTED !! ] In Persian we say "Ajale kare sheytoone" it means that "hurrying is the way of devil" Edited by author 31.10.2009 01:26 In bulgarian it is "Бързата работа срам за майстора" wicch means "Тhe fast work is a shame for the Master". In Vietnamese we say "Muốn nhanh thì phải từ từ" (which means "if you want to be fast, you must be slower") In russian we say "тише едешь, дальше будешь" (which means "if you go slower, you'll be further) same here.. Edited by author 11.12.2017 21:05 the difficulty rangering here is absolutely uncorrect and unjust Edited by author 31.01.2019 04:21 I used template programming to write 3D Fenwick tree and I get "Compiler failed" verdict when compiling with G++ (not "Compilation Error", but "Compiler failed"; no error message). The solution works fine and gets Accepted with Visual Studio and Clang. I assume it is because of the recursive template operations, but it works when I compile it locally with G++ (using the flags provided on help.aspx?topic=cpp). It also work on other online judges, such as codeforces, which also use mingw g++. Could I get some insight on this? I'm curious why this happens. #include <iostream> using namespace std; int main() { long x, y, c, a, b, MIN, MAX; cin >> x >> y >> c; if (x + y < c) { cout << "Impossible"; return 0; } if (x >= c) cout << c << " " << 0; else if (y >= c) cout << 0 << " " << c; else{ if (x < y) cout << x << " " << c - x; else cout << c - y << " " << y ; } } Please, do not publish your accepted solution code on forum. You disable other people to put their mind on the task in such a manner. Please respect other possibility to solve a task on their own. I think that if people don't need an answer they will not watch it. But if they need to see it, an answer is very useful to them, they can find their mistakes and to learn one more variant of programming. Also I watched answers of other people but it absolutely doesn't mean I answered the same on that problems and haven't put my own mind on the tasks. Please, do not publish your accepted solution code on forum. You disable other people to put their mind on the task in such a manner. Please respect other possibility to solve a task on their own. Edited by author 30.01.2019 03:06 |
|
|