| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| 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; } } |
| not clear statements | Ivan Lakhtin`~ | 1738. Компьютерная безопасность | 9 июн 2019 19:00 | 1 |
For those who as I has wa3 or wa5 and don't understand why: 1) similar must be personal number, not passwords 2) personal number is decimal number 3) to get other password (i.e. calculate diffeence of passwords) we can ONLY change digit, we can't insert or erase digits like in personal number May be you don't have theese mistakes, but I spent a day to undestand it |
| ъеъ | vtalgo19_NChernyshev☭ | 1000. A+B Problem | 8 июн 2019 03:21 | 1 |
ъеъ vtalgo19_NChernyshev☭ 8 июн 2019 03:21 |
| Solution Hint | bad dream | 1740. А олени лучше! | 6 июн 2019 14:00 | 1 |
Speed is not constant. It can be 0 or infinity. But it covers each k kilometers in h hours. So, for a segment of length less than k, minimum time is 0 and maximum time is h. Edited by author 06.06.2019 14:01 |
| TLE #62 | Oracle[Lviv NU] | 1589. Сокобан | 6 июн 2019 05:54 | 5 |
TLE #62 Oracle[Lviv NU] 3 ноя 2009 20:40 Can somebody give me some hard test - my program works fine on all tests, which I can think out. BTW, here is some of them: ######## #.OOOOO# #$O$O$O# #OO$O$O# #@O$O$O# ###***O# #......# ######## ######## #.O$OO.# #O$..$O# #$$..$O# #O$..$$# #@$O.$O# #..$OO.# ######## ######## #.O$OO.# #O$..$O# #$$..$O# #O$..$$# #@$..$O# #.O$OO.# ######## ######## #......# ###***O# #@O$O$O# #OO$O$O# #$O$O$O# #.OOOOO# ######## ######## #.....O# #$$$$$O# #OO...O# #$$$$$O# #O.OO$.# #.O$.$+# ######## ######## #......# ###***O# #@O$O$O# #OO$O$O# #OO$O$O# #OOOOOO# ######## ######## #.$.$OO# #@OOOOO# #O$$$$$# #O.....# #$$$$$$# #......# ######## ######## #.OOO.O# #@$O##O# #OOO*OO# #.$O$O$# #$$$$..# #...OOO# ######## ######## #OOOO.O# #@OO##O# #OOO*OO# #.$O$OO# #$$$$.O# #...OOO# ######## ####### #@$OO.# #$O$OO# #.O.OO# ####### P.S. space I've changed to O. Edited by author 03.11.2009 20:42 I have TLE 62 too. Don't have ideas of how to proceed. Can you give a hint of how you have improved you program to pass this test? I've stored only those positions, which can not be processed in some steps by greedy algo + store only positions, where man is in lowest-left cell + stop, when position is surely bad (I've used a lot of classes of bad positions) + make moves, that is surely necessary. Hi Oracle, can u give us some cases that considered as a bad position? I have a prunning issue also on my solution |
| Почему ваш компилятор не видит директиву "stdafx.h" | Ilya | 1000. A+B Problem | 5 июн 2019 15:50 | 2 |
#include "stdafx.h" #include <iostream> int main() { int a; int b; int c; scanf_s("%d%d\n", &a, &b); c = a + b; printf("%d\n", c); return 0; } Зачем тебе эти директивы вообще? Нужна только айострим. И пишется так: <stdafx.р> |
| Всё оч просто.с++ | Kostya | 1000. A+B Problem | 5 июн 2019 15:47 | 1 |
#include <iostream> using namespace std; int main() { long long a, b; cin >> a >> b; cout << a+b; } |
| Any other suggestion? | adityarev | 1589. Сокобан | 5 июн 2019 12:53 | 2 |
Hi guys, i've tried to solve this problem with A*. I came with pull distance as heuristic and calculate the distance table with Floyd's algorithm. I also have put deadlock detector (for Simple and Frozen) on my code. Is there something i miss? Or do you have any other suggestion? I am very happy if i can discuss with you guys. Thanks before for your help :) I know some interesting optimisations which helped me get TLE 78 but I don't understand how to use A* in this problem. Let's discuss it. My email is imoskovchenko72@gmail.com |
| for those ,who don't know what to do with WA 7,8; | Ivan | 1131. Копирование | 4 июн 2019 22:49 | 1 |
I tried to pick up to my occasion all data types ,but there was some problem ;Then i tried using data type "auto" and it's worked! |
| What's test#19 ? anything must notice? | tbtbtb | 1332. Джинн-бомбардировки | 4 июн 2019 11:08 | 6 |
I got WA#19 too! Any tricky test here? test 19 is like this 2 1 1 101 101 2 1 Your answer is probably 0 The right one is 1 Thank you, that was really helpful! |
| Thanks for such a cool problem | Md sabbir Rahman | 2124. Алгебра на отрезке | 4 июн 2019 07:06 | 1 |
Whoever made this problem, thanks a lot! Seeing group theory applied in cp felt pretty cool. Alos learnt a lot thanks to this problem |
| Precision errors? | Timothy Mou | 2121. Пересечение парабол | 3 июн 2019 20:29 | 3 |
I believe I am having precision errors when calculating the solution. I changed from doubles to long doubles and got one more test case, so I believe my solution is correct but not precise enough. Any tips to resolve this? Never mind, there was simplification in the calculations and then I just hard-coded printed out the decimals. This problem is just cancer Yes Some tests: a = 1 ans = 3.666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667 a = 1.5 ans = 5.666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667 a = 666 ans = 2663.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666674 a = 1000000000000000000 ans = 3999999999999999999.666666666666666666666666666666666666666666666666666666666666666333333333 Edited by author 03.06.2019 20:30 |