| Show all threads Hide all threads Show all messages Hide all messages |
| WA#8 | Juan Pablo | 1045. Funny Game | 6 May 2016 21:27 | 1 |
WA#8 Juan Pablo 6 May 2016 21:27 my code is wrong in the test 8 but i dont know the test, can you help me? |
| Test #1? Whats wrong with my code? | Shavkat_bek | 2023. Donald is a postman | 6 May 2016 18:42 | 2 |
#include<iostream> #include<cstring> #include<cmath> using namespace std; int main(){ string st; int W,n,i=0,A[1000]; cin >> n; do{ cin >> st; if(((int)st[0]==65)||((int)st[0]==80)||((int)st[0]==79)||((int)st[0]==82)) A[i]=1; if(((int)st[0]==66)||((int)st[0]==77)||((int)st[0]==83)) A[i]=2; if(((int)st[0]==68)||((int)st[0]==71)||((int)st[0]==74)||((int)st[0]==75)||((int)st[0]==84)||((int)st[0]==87)) A[i]=3; i++; }while(i<n); for(i=0;i<n-1;i++) { int S; S=abs(A[i]-A[i+1]); W+=S; } cout<<W; return 0; } Please,help me!!! Edited by author 06.05.2016 18:42 |
| HELP ME (TIME LIMIT EXCEEDED) !! Python how to do | supanat | 1048. Superlong Sums | 5 May 2016 22:41 | 2 |
import sys n = input() arr = bytearray(n) i = 0 while i < n: line = raw_input().split() arr[i] = (int(line[0]) + int(line[1])) i += 1 result = "" i = n-1 while i > 0: if arr[i] > 9: arr[i] -= 10 arr[i-1] += 1 result = str(arr[i]) + result i -= 1
arr[0] = arr[0]%10 result = str(arr[0]) + result print result result = str(arr[i]) + result Run this code 1M iterations locally. |
| Why so? | IlushaMax | 1457. Heating Main | 5 May 2016 14:50 | 1 |
f(x) = k * (x^2 -2(a1)x + (a1)^2 + x^2 -2(a2)x + (a2)^2 + ... + x^2 -2(an)x + (an)^2) / n = k (x^2 - (2/n)(a1 + a2 + ... + an)x + ((a1)^2 + (a2)^2 + ... + (an)^2)/n so we have f'(x) = k(2x - (2/n)(a1 + a2 + ... + an)) question: what is k? (explaining from previus post) Edited by author 05.05.2016 14:53 Edited by author 05.05.2016 14:54 |
| Getting wrongs. WA 9 now WA 5. | Dhruv Somani | 1106. Two Teams | 4 May 2016 14:28 | 1 |
Earlier I had got a WA 9 but now I'm getting a WA 5 with the same code. What's the logic? |
| O(N^2) idea, works fine | Marian Darius | 1297. Palindrome | 3 May 2016 22:00 | 3 |
4686044 16:50:13 21 Dec 2012 Marian Darius 1297. Palindrome C++ Accepted 0.031 108 KB Just try iterating the middle of the palindrome and extend to both ends, until you find two elements that are different. Seriously? Are you really think that you are the first who do it for O(N^2) with the same idea? And it's not the first topic in the forum about this algo. I don't know why but I get a TLE in #15 with the same approach as yours. |
| Hallelujah, how did you solved this problem so quickly? | Anatoliy V Tomilov | 1589. Sokoban | 2 May 2016 16:19 | 2 |
3 days overall. I'm your fan forever. Edited by author 03.05.2016 14:58 Can you give us some tips on your approach? Thanks in advance. Edited by author 03.05.2016 14:58 |
| WA #2 | ed1688 | 1127. Colored Bricks | 2 May 2016 05:32 | 2 |
WA #2 ed1688 2 May 2016 00:19 Can someone help to post test #2? Thanks |
| It is easy, just sort and one linear cycle | Sanatbek_Matlatipov | 1203. Scientific Conference | 1 May 2016 22:22 | 2 |
1. Sort it by endTime, if endTime equals another endTime then sort them by startTime. 2. Open one iteration from 2 to n, init just check that, is endTime<starTime, if so then ans++; 3. print ans; endTime and startTimes is one array with unchanged same index... Sorry for poor English
I don't think sorting by startTime is necessary. I think we should reverse-sort by startTime. |
| My algo is right but wa1 (on sample I have right answer). Where is mistake? | IlushaMax | 1601. AntiCAPS | 1 May 2016 17:15 | 1 |
I found hah) Edited by author 01.05.2016 17:16 |
| My solution with ASCII codes | IlushaMax | 1404. Easy to Hack! | 29 Apr 2016 22:53 | 1 |
|
| test12 | Anny Kyort | 2027. URCAPL, Episode 1 | 29 Apr 2016 18:40 | 2 |
test12 Anny Kyort 29 Nov 2014 12:02 What is the 12 test? Edited by author 29.11.2014 12:19 It's about time limit exceed. |
| Hi to everyone. Why its WA3 | Bartenal | 1294. Mars Satellites | 29 Apr 2016 15:29 | 1 |
import math values = raw_input().split(' ') a = float(values[0]) b = float(values[1]) c = float(values[2]) d = float(values[3]) if (math.fabs(a*b-c*d)<0.001): print "Impossible."
j = 0.0 x = a**2 + b**2 #DC**2(1) y = c**2 + d**2 #DC**2(2) x1 = - 2 * a * b y1 = - 2 * c * d l = math.fabs(x - y) r = math.fabs(x1 - y1) if r == 0: False else: j = l / r #cos res = a**2.0 + b**2.0 - 2.0 * a * b *j #DC**2 res = math.sqrt(res)*1000 #DC print "Distance is %(res)d km." %{"res": res} Edited by author 29.04.2016 15:30 Edited by author 29.04.2016 16:01 |
| WA9 WHY??? | romanula | 1601. AntiCAPS | 29 Apr 2016 12:34 | 5 |
new one but still WA9 package banky; import java.util.*; public class test1 { private static Scanner scan; public static void main(String [] args){ scan = new Scanner(System.in); int k=0; int r=0; int pr=0; while (scan.hasNext()){ String s = scan.nextLine(); //s = s.toUpperCase(); s = s.toLowerCase(); char c [] = s.toCharArray(); if (k<=0||r>0) c[0] -= 32; int i ; for(i=1;i<s.length();i++){ if ((c[i] == 46) || (c[i] == 33) || (c[i] == 63)) {pr= 1; c[i]=c[i];} else if (pr==1&&c[i]!=32) { c[i] -= 'a' - 'A'; pr = 0;}} for(i=0;i<s.length();i++){ if ((c[i] == 0)|| (c[i] == 14) || (c[i] == 1) || (c[i] == 31)) c[i] += 'a' - 'A';} for(i=1;i<s.length();i++){ if (((c[i-1]< 'a')&&(c[i-1]>='A'))&&((c[i]< 'a')&&(c[i]>='A'))) {c[i] += 'a' - 'A';}}
if ((c[s.length()-1] == 46) || (c[s.length()-1] == 33) || (c[s.length()-1] == 63)) {r=r+1;} else {r=0;} //System.out.println(k); //System.out.println(r); System.out.println(c); k=k+1; } } } Edited by author 30.04.2016 13:09 You are checking the only prev char for end of sentence. Why? Try "HERE!!! IS!!!!! TEST!!!!" P.S. Why "c[i]==32" better then "c[i]==' '"? Дякую, за тест. І що мені робити? :( Edited by author 29.04.2016 11:37 Implement state machine, ~2 states: 1) "at sentence begin", if char is alpha then it uppercased, state switched to "inside sentence" 2) "inside sentence", if char is alpha it lowercased; if char is ".?!" state switched to "at sentence begin". Thank you for help. But I am only beginer in java so i cant jet deal with this state machine Implement state machine, ~2 states: 1) "at sentence begin", if char is alpha then it uppercased, state switched to "inside sentence" 2) "inside sentence", if char is alpha it lowercased; if char is ".?!" state switched to "at sentence begin". |
| Please help me to continue my solution | IlushaMax | 1120. Sum of Sequential Numbers | 29 Apr 2016 01:03 | 1 |
I've got quadratic equation. It can be calculated if you know just what is arithmetical progression. What I should to know in maths to find max P (I found P from the equation). Edited by author 29.04.2016 01:05 |
| Работающая версия [Worked] | sovaz1997 | 1787. Turn for MEGA | 28 Apr 2016 09:24 | 2 |
#include <iostream> using namespace std; int main() { int mashines, minutes; cin >> mashines >> minutes;
int arr[minutes];
for(int i = 0; i < minutes; ++i) {cin >> arr[i];}
int m = 0; for(int i = 0; i < minutes; ++i) { m += arr[i];
if(m - mashines >= 0) {m -= mashines;} else {m = 0;} }
cout << m; } а тебе разрешили инициализировать массив с НЕ const параметром? Edited by author 28.04.2016 09:29 |
| My mistake | Arseniy_Pavlov | 1208. Legendary Teams Contest | 27 Apr 2016 18:33 | 1 |
Hah I decided to check all variants, but due to misprint my program become greedy) |
| Test case # 11 fails for me. | grey under sky | 1106. Two Teams | 27 Apr 2016 16:37 | 5 |
#include <iostream> using namespace std; long f[101],n; int main() { long i,t,c=0; cin>>n; for (i=1;i<=n;i++) { if (f[i]==0) f[i]=1; while (true) { cin>>t; if (t==0) break; if (f[t]==0) f[t]=1+(f[i]==1); } if (f[i]==1) c++; } cout<<c<<endl; for (i=1;i<=n;i++) if (f[i]==1) cout<<i<<" "; } why?? I had WA 11, this test helped me: 4 2 0 1 4 0 4 0 2 3 0 Edited by author 30.10.2007 04:07 What's the main idea behind it? |
| What's the test case #11? | Dhruv Somani | 1106. Two Teams | 27 Apr 2016 16:34 | 1 |
I am getting a wrong answer in it. Can anyone please help me? |
| Please help me! I do not know how to charge the time. | Hunter | 1021. Sacrament of the Sum | 27 Apr 2016 14:58 | 3 |
#include<stdio.h> #include<stdlib.h> int main() { int m,n,a[50000],b[50000],i,j,p,c; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d",&b[i]); } for(j=0;j<n;j++) { for(p=0;p<m;p++) { c=a[j]+b[p]; if(c==10000) { printf("YES"); exit(0); } } } printf("NO"); return 0; } in my mind, two loops is not required. Try to use binary search in sorted array. steps: 1.Take from first array the number; 2.1000-[this number] 3.find 1000-[this number] in second array(use binary search) This way, you have only one loop. Edited by author 20.11.2015 23:45 Edited by author 20.11.2015 23:45 |