| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| Manacher Algorithm! | GastonFontenla | 1297. Палиндромы | 21 июн 2019 11:44 | 2 |
Hi! I'm just amazed about this algorithm! My previous O(N^3) implementation take 0.624 and 508 KB with my best efforts to reduce runtime. When I submitted the Manacher's one, the runtime dropped down to 0.015 and 2376 KB!! Just google it. It's a very easy and efficient O(N) algorithm. That's all you need to solve this problem. No more than 30 lines of code. Do u give me your implemented solution? |
| Please tell me the possible outputs for n = 1-8 and k = 10 | Darwesh | 1009. K-ичные числа | 20 июн 2019 17:58 | 3 |
Can anyone please tell me in tabular form what is are the values of answers for the above values. My algorithm is almost right and it is calculating accurately as far as I know but it is always responding No on test # 2. Please help!!! I am stuck and dissappointed.... :( 1 10 -> 9 2 10 -> 90 3 10 -> 891 4 10 -> 8829 5 10 -> 87480 6 10 -> 866781 7 10 -> 8588349 8 10 -> 85096170 ... 88 10 -> 4073204239463162109734811048211023806979858806092557057802513502380259034152215057201989 how for k=3 it should be 90 |
| Give me example plz | Dias_97 | 1009. K-ичные числа | 20 июн 2019 17:37 | 4 |
input 3 5 output : 96 input 10 2 output: 89 Edited by author 14.04.2019 17:30 Edited by author 14.04.2019 17:36 |
| WA#18 | Oleg1209 | 1436. Рекламный щит | 20 июн 2019 16:21 | 2 |
WA#18 Oleg1209 12 окт 2015 13:09 What is the test 18? I really don't understand it... I wrote solution with ternary search, and I think that there is problem with accuracy of calculations. Have anybody this problem? P.S. Sorry for my bad english :) You should find number extremum of function. Spoiler: It isn't true, that there is only one. Edited by author 20.06.2019 16:21 |
| 1001. Reverse Root | Suraj Sharma | 1001. Обратный корень | 20 июн 2019 11:03 | 1 |
The following code is failing the test case 3, I have used linked-list to store the data in as a stack. Below is the code for reference, can you tell me where I am going wrong. Thank you. #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<math.h> #include<assert.h> typedef unsigned long long _ull; typedef unsigned int _uint; typedef struct _link_list { _ull _number; struct _link_list*_next; } _list; void _makenode(_list**,_ull); void _insertnode(_list**,_list*); int main(int argc,const char*argv[]) { _ull _val; _list *_head,*_temp; _head = _temp = NULL; while(true) { fscanf(stdin,"%lld",&_val); assert(_val>=0); if(feof(stdin)) break; _makenode(&_head,_val); } while(_head) { _temp = _head; fprintf(stdout,"%0.4lf\n",sqrt(_head->_number)); _head = (_head->_next); free(_temp); } return 0; } void _makenode(_list**_ptr,_ull _data) { _list*_node = malloc(sizeof(_list)); (_node->_number) = _data; (_node->_next) = NULL; _insertnode(_ptr,_node); } void _insertnode(_list**_ptr,_list*_node) { if(!(*_ptr)) (*_ptr) = _node; else { (_node->_next) = (*_ptr); (*_ptr) = _node; } } |
| Random Test Cases | Aditya Singh | 1138. Целочисленные проценты | 19 июн 2019 08:04 | 2 |
Try testcases 12 11 1 12 10 2 100 7 7 20 7 2 1000 1 26 10000 1 37 10000 13 25 100 25 8 |
| Can you explain this problem? | bad dream | 1964. Китайский язык | 18 июн 2019 18:10 | 1 |
Can you please explain what this problem is asking? Input: 10 2 8 8 Output: 6 Input: 10 3 8 8 8 Output: 4 Can you explain how the output is changing? What's the logic/intuition behind this? Please explain in details. |
| Help me! Please WA_7 | Jica | 1837. Число Исенбаева | 17 июн 2019 13:09 | 4 |
___Test 13 Fominykh Isenbaev BBB BBB CCC AAA Ayzenshteyn Oparin Samsonov Ayzenshteyn Chevdar Samsonov Dublennykh Fominykh Ivankov Burmistrov Dublennykh Kurpilyanskiy Cormen Leiserson Rivest Oparin AA AAA Isenbaev Oparin Toropov AA DD PP PP QQ RR RR SS TT TT Toropov Oparin ____correct answer: AA 2 AAA 2 Ayzenshteyn 2 BBB 1 Burmistrov 3 CCC 2 Chevdar 3 Cormen undefined DD 3 Dublennykh 2 Fominykh 1 Isenbaev 0 Ivankov 2 Kurpilyanskiy 3 Leiserson undefined Oparin 1 PP 3 QQ 4 RR 3 Rivest undefined SS 3 Samsonov 2 TT 2 Toropov 1 Thank you very much - I had WA7 and this test helped me very much. I realized that some of the numbers on my output were higher (I didn't take the shortest path in the graph). You need to take the shortest path and not the first path found. I have correct answers but still cannot pass test 7 |
| Test #1 runtime error | roman velichkin | 1837. Число Исенбаева | 17 июн 2019 13:00 | 2 |
[code deleted] Edited by moderator 19.11.2019 23:08 problem was caused by comments, removed them and everything worked |
| Why wrong(C++) (incorrect input)? | Ilya | 2100. Свадебный обед | 16 июн 2019 18:07 | 1 |
#include <iostream> #include <string> using namespace std; int main() { int n,i,k=2; string s; cin>>n;
for (i=1;i<=n;++i) { getline(cin,s); if (s.find("+")!=string::npos) k+=2;
else ++k; }
if (k==13) ++k;
cout<<k*100;
return 0; } Edited by author 16.06.2019 18:08 Edited by author 16.06.2019 18:08 |
| WA11 | 👨💻tproger👨💻[GTGU] | 1707. Секрет Гипножабы | 14 июн 2019 23:31 | 2 |
WA11 👨💻tproger👨💻[GTGU] 14 июн 2019 14:36 Is it special test? I have no idea, what is wrong with my implementation. Re: WA11 👨💻tproger👨💻[GTGU] 14 июн 2019 23:31 Yes, it is. It is the first (or may be not) test with negative delta's (Δs, Δt, and so on). |
| I need help!! anyone | Egor | 1030. Титаник | 14 июн 2019 22:54 | 2 |
Hello! I`ve got a code, equations must be right, but the result is different from sample. I don`t know what the problem is. Please, help!! My result is 45,28, whereas the sample`s one is 52,04. static void Main(string[] args) { const double D = 6875; const double pi = 3.1415926535897932384626433; string trash; char[] separators = new[] { ' ', '^', '"', '\''}; /* double shipx, shipy, shipz, icex, icey, icez; */ for (int i = 0; i < 3; i++) trash = Console.ReadLine(); var shipLat = Console.ReadLine().Split(separators); var shipLong = Console.ReadLine().Split(separators); trash = Console.ReadLine(); var iceLat = Console.ReadLine().Split(separators); var iceLong = Console.ReadLine().Split(separators); trash = Console.ReadLine(); double phi1 = (int.Parse(shipLat[0]) + (int.Parse(shipLat[1]) + int.Parse(shipLat[2]) / 60) / 60) * (pi / 180); double phi2 = (int.Parse(shipLong[1]) + (int.Parse(shipLong[2]) + int.Parse(shipLong[3]) / 60) / 60) * (pi / 180); if (shipLat[3] == "SL") phi1 = -phi1; if (shipLong[4] == "WL") phi2 = -phi2; double L1 = (int.Parse(iceLat[0]) + (int.Parse(iceLat[1]) + int.Parse(iceLat[2]) / 60)/60) * (pi / 180); double L2 = (int.Parse(iceLong[1]) + (int.Parse(iceLong[2]) + int.Parse(iceLong[3]) / 60)/60) * (pi / 180); if (iceLat[3] == "SL") L1 = -L1; if (iceLong[4] == "WL") L2 = -L2; double ans = Math.Acos(Math.Sin(phi1) * Math.Sin(L1) + Math.Cos(phi1) * Math.Cos(L1) * Math.Cos(L2-phi2)); double dist = ans * D/2; Console.Write("The distance to the iceberg: "); Console.WriteLine("{0:0.00}", dist); if (100.00 - dist > 0.005) Console.WriteLine("DANGER!"); } The problem is solved. It`s impossible to have the right answer with INT parsing. You need to use double. |
| Don't be afraid to use string | Skeef79 | 1102. Странный диалог | 13 июн 2019 20:21 | 1 |
I just cin every string and then solve using it. 0.156 accepted |
| Is it a "Nim"-game??? | enick | 1087. Время забирать камни | 13 июн 2019 16:59 | 3 |
|
| another tricky test case incase you get WA but don't know what to do . . . | Sam Green | 1280. Topological Sorting | 12 июн 2019 21:59 | 2 |
1 1 1 1 1 the answer must be "NO", not "YES" Edited by author 27.04.2007 09:34 My Program says "YES" and i got accepted |
| Guys I got a ques. | Ibragim Atadjanov (Tashkent U of IT) | 1671. Паутина Ананси | 12 июн 2019 21:19 | 2 |
If its not a multy eadge and it is a bridge, then it increase the number of pieces by one otherwise the pieces amount left same. Am I right? It is so hard to solve it this way, because you have to recalculate bridges after every delete. You should try disjoint-set-union this data structure is so awesome and simple to write. |
| 0.109s answer | dula | 1654. Шифровка | 12 июн 2019 11:39 | 6 |
#include<iostream> #include<string.h> #include<deque> #include<stdio.h> using namespace std; int main() { string node; cin >> node; int one,two; one = 0; two = 1; int pre = 0; for(int i = 0;i < node.size();i++) { if(node[i] == '!') continue; if(node[i] == node[i+1]) { node[i] = node[i+1] = '!'; one = pre; if(i+2 < node.size()) two = i+2; while(one> 0 && two < node.size()) { while(one > 0 && node[one] == '!') one--; if(node[one] == node[two] ) { node[one] = node[two] = '!'; one--;two++; } else break; } } else pre = i; }
for(int i = 0;i < node.size();i++) { if(node[i] != '!') cout << node[i]; }
} I use stack and my solution works 0.064s :) My solution works 0.048s ;) Why your solutions is right? if input is: sddssdds then your ans is "ss"! |
| Why WA? | ANTAR NANDI | 1409. Два бандита | 11 июн 2019 15:05 | 1 |
Why WA? ANTAR NANDI 11 июн 2019 15:05 |
| why not? 1 test | Lev_IZR123 | 1910. Руины титанов: сокрытый вход | 10 июн 2019 17:23 | 3 |
Wrong answer 1 test #include <iostream> using namespace std; int main() { int n, i, x, max; int mas[1000];
cin >> n; max = 0; for (i = 0; i < n; i++) { cin >> mas[i]; } max = mas[0] + mas[1] + mas[2]; x = 1; for (i = 1; i < n; i++) { if (mas[i] + mas[i + 1] + mas[i + 2] > max) { max = mas[i] + mas[i + 1] + mas[i + 2]; x = i + 1; } } cout << max << ' ' << x + 1 << endl; system("pause"); return (0); } Because for i = n - 1, mas[i + 1] and mas[i + 2] go out of bounds |
| help c++ | Barbs | 1910. Руины титанов: сокрытый вход | 10 июн 2019 17:22 | 4 |
#include <iostream> using namespace std; int main() { int a[1000]; int n=0,s,sx=0,m=0; cin >> n; for(int i=0;i<n;i++){ cin >> a[i]; } for(int u=1;u<n-1;u++){ s=a[u]+a[u+1]+a[u+2]; if(s>sx){ sx=s; m=u+1; }} if (n==3){ sx=a[0]+a[1]+a[2]; m=2; } cout << sx << " " << m << endl; } #include<iostream> using namespace std; int main() { int numSection; cin >> numSection; int a[numSection]; for (int i = 0; i < numSection; i++) { cin >> a[i]; } int n = numSection - 3 + 1; int max = 0; int middleNumSec = 0; for (int i = 0; i < n; i++) { if (i + 3 > numSection) { break; } int sum = 0; for (int j = i; j < i + 3; j++) { sum += a[j]; } if (sum > max) { max = sum; middleNumSec = i + 2; } } cout << max << " " << middleNumSec << endl;
system("pause"); return 0; } My solution: #include <iostream> #include <string> #include <vector> #include <set> #include <queue> #include <map> #include <stack> #include <algorithm> #include <bitset> #include <cstring> #include <cmath> #include <cstdlib> #include <cstdio> #include <iomanip> #define F first #define S second #define ll long long #define len length() #define sqr(x) x*x #define pb push_back #define mp make_pair #define sz(x) ((int) (x).size()) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define bp(x) __builtin_popcount(x) #define INF numeric_limits<long long int>::max() #define frp freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++) const int maxn = (int)1e6; const int mod = (int)1e9 + 7; using namespace std;
int n; int a[maxn]; int sum,ans; int cnt; main(){ scanf("%d",&n); for(int i=1; i <= n; i++){ scanf("%d",&a[i]); } for(int i=1; i <= n-2; i++){ sum=a[i]+a[i+1]+a[i+2]; if(ans < sum){ ans=sum; cnt=i+1; } } printf("%d %d",ans,cnt);
return 0; } OMG man, thank u) this is correctly #include <iostream> using namespace std; int a[1000], n = 0, s, sx = 0, m = 0; void main() {
cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int u = 0; u < n; u++) { s = a[u] + a[u + 1] + a[u + 2]; if (s > sx) { sx = s; m = u + 2; } } |