| Show all threads Hide all threads Show all messages Hide all messages |
| AC in c++ | Yucheng | 1048. Superlong Sums | 12 Feb 2019 20:34 | 1 |
#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; } |
| Maybe this will help you! | LmhQ_C | 1354. Palindrome. Again Palindrome | 12 Feb 2019 19:14 | 5 |
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? |
| WA2? | Sherxon | 1982. Electrification Plan | 12 Feb 2019 17:57 | 2 |
WA2? Sherxon 26 Nov 2016 03:19 Can anybody please give me cases for Test2 ? Re: WA2? Manole Victor 12 Feb 2019 17:57 If you only go through the matrix and saved the minimum value, it is not the solution for that problem. |
| TEST FOR WA4 | Dmitry Vaskin`~ | 1786. Sandro's Biography | 12 Feb 2019 14:54 | 1 |
|
| Transitive closure using std::bitset | Gilles Deleuze | 1487. Chinese Football | 10 Feb 2019 20:10 | 1 |
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]; } } |
| Poor centipede :-D | Brooklyn | 1876. Centipede's Morning | 9 Feb 2019 21:20 | 2 |
|
| Why my algo is right? | __Andrewy__ | 1769. Old Ural Legend | 9 Feb 2019 17:21 | 2 |
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 |
| No subject | Sanchir | 1787. Turn for MEGA | 8 Feb 2019 11:03 | 1 |
Edited by author 11.02.2019 20:58 |
| Runtime error (access violation) #8 | Andor Vari-Kakas | 1042. Central Heating | 5 Feb 2019 02:27 | 1 |
|
| It's interesting.. | John Doe | 1001. Reverse Root | 5 Feb 2019 01:03 | 1 |
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; } |
| Not a word about input precision | Sirko | 1340. Cucaracha | 1 Feb 2019 23:07 | 1 |
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 |
| VERY FUNNY STORY! | Shogal [Kaliningrad] | 1293. Eniya | 31 Jan 2019 17:20 | 12 |
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 |
| WHY this sht has difficulty 81?!!! | mmd18cury | 1194. Handshakes | 31 Jan 2019 04:21 | 1 |
the difficulty rangering here is absolutely uncorrect and unjust Edited by author 31.01.2019 04:21 |
| "Compiler failed" verdict with G++? | mouse_wireless2 | 1470. UFOs | 31 Jan 2019 00:19 | 1 |
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. |
| C++ AC | mmd18cury | 2035. Another Dress Rehearsal | 30 Jan 2019 03:03 | 3 |
C++ AC mmd18cury 2 Jan 2019 08:00 #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 ; } } Re: C++ AC Smilodon_am [Obninsk INPE] 2 Jan 2019 12:33 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 |
| what is my problem on c++? | nick nikuradze | 1910. Titan Ruins: Hidden Entrance | 29 Jan 2019 02:16 | 2 |
This is my code. #include <iostream> #include <vector> using namespace std; int main() { int n,a,k=0; cin>>n; vector <int> v; vector <int> sum; vector <int> index; for(int i=0; i<n; i++) { cin>>a; v.push_back(a); } for(int i=1; i<n-1; i++) { sum.push_back(v[i-1]+v[i]+v[i+1]); index.push_back(i); } int max=sum[0]; for(int i=1; i<n; i++) { if(sum[i]>max) {max=sum[i]; k=i;} } cout<<max<<" "<<index[k]+1; system("pause"); return 0; } If you look carefully, you don't get n sums and indexes, but actually n-2 sums and indexes. |
| HINT | Michael Jordan | 1353. Milliard Vasya's Function | 28 Jan 2019 14:43 | 1 |
HINT Michael Jordan 28 Jan 2019 14:43 just be patient while making precalculation :) |
| Я и Балл | SpamBot | 1639. Chocolate 2 | 28 Jan 2019 02:47 | 1 |
Жеванный крот, одна халтура! Мало того что английский перевод кривой как рог барана, так ещё и проверяющая система хромает! Отправляем на проверку: Var s, s1: ansistring; a, b: byte; Begin readln(s, s1); val(s[length(s)], b); End. Получаем вполне обоснованный WA1. Теперь дополним: Var s, s1: ansistring; a, b: byte; Begin readln(s, s1); val(s[length(s)], b); val(s1[length(s1)], a); End. Всё, вселенная дрогнула: "Access violation"... *facepalm* И всё бы ничего, но подобное происходит уже где-то раз пятый (в разных задачах). И да, прочитать string целиком, а затем разрезать - выдаёт ту же ошибку AV: Var s, s1: ansistring; i, a, b: byte; Begin readln(s); for i:=1 to length(s) do if s[i]:=' ' then begin val(s[i-1], b); val(s[length(s)], a); break; end; End. Сделайте уже нормальный ввод!!!!1 |
| No subject | dgdfgfdg | | 27 Jan 2019 16:11 | 1 |
Edited by author 01.02.2020 21:32 |
| C++ AC | mmd18cury | 1106. Two Teams | 26 Jan 2019 19:52 | 1 |
C++ AC mmd18cury 26 Jan 2019 19:52 I recommend you this resource: https://e-maxx.ru/algo/bfsalso you can make a function instead of the lyambda, but I just like lyambdas more. #include <iostream> #include <vector> #include <queue> using namespace std; int main() { int N; cin >> N; vector <vector <int>> g(N); int h; for (int i = 0; i < N; i++) { for (;;) { cin >> h; if (!h) break; g[i].push_back(h - 1); } } int n = g.size(); queue<int> q; vector<bool> used(n); vector<int> d(n); int s; auto bfs = [&](int start) { s = start; q.push(s); used[s] = true; while (!q.empty()) { int v = q.front(); q.pop(); for (size_t i = 0; i<g[v].size(); ++i) { int to = g[v][i]; if (!used[to]) { used[to] = true; q.push(to); d[to] = d[v] + 1; } } } }; for (int start = 0; start < n; ++start) if (!used[start]) { bfs(start); } vector <int> ans; for (int i = 0; i < n; i++) { if (d[i] % 2 == 0) ans.push_back(i + 1); } int size = ans.size(); cout << size << '\n'; for (int i = 0; i < size; i++) cout << ans[i] << " "; } Edited by author 26.01.2019 22:53 Edited by author 30.01.2019 03:16 |