| Show all threads Hide all threads Show all messages Hide all messages |
| I have WA#6 :( | Roma | 1345. HTML | 15 May 2014 00:06 | 1 |
Please, help me. My code: #include <iostream> #include <cstring> #include <cctype> using namespace std; const int MaxSourceSize = 100000; const int MaxBuffSize = 1000; const int nKeyWord = 36; const char *comment_start = "<span class=comment>"; const char *keyword_start = "<span class=keyword>"; const char *string_start = "<span class=string>"; const char *number_start = "<span class=number>"; const char *end_teg = "</span>"; const char KeyWords[nKeyWord][sizeof( "implementation" )] = { "and", "array", "begin", "case", "class", "const", "div", "do", "else", "end", "for", "function", "if", "implementation", "interface", "mod", "not", "of", "or", "procedure", "program", "record", "repeat", "shl", "shr", "string", "then", "to", "type", "unit", "until", "uses", "var", "with", "while" }; int main() { register int i, j, g; char source[MaxSourceSize]; cin.get ( source, MaxSourceSize, 0 ); cin.ignore(); for ( i = 0; source[i]; i++ ) { if ( isalpha ( source[i] ) || source[i] == '_' ) { char buff[MaxBuffSize]; bool itKeyWord = false; for ( g = i, j = 0; isalnum ( source[g] ) || source[g] == '_'; g++, j++ ) buff[j] = tolower ( source[g] ); buff[j] = 0; for ( j = 0; j < nKeyWord; j++ ) if ( !strcmp ( buff, KeyWords[j] ) ) { itKeyWord = true; break; } if ( itKeyWord ) cout << keyword_start; for ( i; isalnum ( source[i] ) || source[i] == '_'; i++ ) cout << source[i]; i--; if ( itKeyWord ) cout << end_teg; } else { if ( isdigit ( source[i] ) ) { cout << number_start; for ( i; isdigit ( source[i] ) || ( source[i] == '.' && source[i+1] != '.' ); i++ ) cout << source[i]; i--; cout << end_teg; } else { switch ( source[i] ) { case '{': { int in = 0; cout << comment_start; for ( ; ; i++ ) { if ( source[i] == '{' ) in++; else if ( source[i] == '}' ) { in--; if ( !in ) {cout << source[i];break;} } cout << source[i]; } cout << end_teg; //i--; };break; case '\\': { if ( source[i+1] == '\\' ) { cout << comment_start; for ( i; source[i] != '\n'; i++ ) cout << source[i]; cout << end_teg; i--; } else { cout << '\\'; } };break; case '\'': { cout << string_start; cout << source[i++]; for ( i; source[i] != '\''; i++ ) cout << source[i]; cout << source[i]; cout << end_teg; };break; case '#': { cout << string_start; i++; cout << "#"; for ( i; isdigit ( source[i] ) || ( source[i] == '.' && isdigit ( source[i+1] ) ); i++ ) cout << source[i]; cout << end_teg; i--; };break; default: { cout << source[i]; };break; } } } } return NULL; } |
| Anybody get WA#10? | MAI.8 | 1482. Triangle Game | 14 May 2014 18:03 | 5 |
I cann't understand why WA#10. Must I use long double? Please, give me some terrible tests. I got WA on test 10 too. And it's a little bit strange because the algo is simple. Maybe there are some problems with "10 fractional digits"... 0-result must be established in int64 only use 6 permutations for vertices of aim triangle also long double won't help because it's same type as double in VC++ As for 6 permutations, I think there must be only 3. Otherwise we'll consider flip-overs. I cann't understand why WA#10. Must I use long double? Please, give me some terrible tests. long double4 is normal. Use EPS = 0.00000001; if use EPS = 0.00000000001 then get WA11. |
| Accepted C# | Developer | 1000. A+B Problem | 14 May 2014 17:55 | 1 |
using System; public class Sum { private static void Main() { string[] tokens = Console.ReadLine().Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } |
| Accepted C# | Developer | 1209. 1, 10, 100, 1000... | 14 May 2014 17:54 | 1 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace T1 { class Program { static void Main(string[] args) { //List<int> n = new List<int>(); List<long> ans = new List<long>(); long s = System.Int64.Parse(Console.ReadLine()); for (int i = 0; i < s; i++) { int x = int.Parse(Console.ReadLine()); ans.Add(Find(x)); } for (int i = 0; i < s; i++) { Console.Write(ans[i]); Console.Write(" "); } //Console.ReadKey(); } static long Find(long x) { // (a)n^2 + (b)n - (c)2x = 0 // a = 1 // b = 1 // c = 2 * x double a = 1, b = 1, c = - 2 * x + 2; double d = b * b - 4 * a * c; double p = (-b + Math.Sqrt(d)) / 2 * a; return (p - (long) p) > 0 ? 0 : 1; } } } |
| Accepted C# | Developer | 1068. Sum | 14 May 2014 17:53 | 1 |
using System; using System.Linq; using System.Text; namespace Sum { class Program { static void Main(string[] args) { int x, p = 0; x = int.Parse(Console.ReadLine()); if (x < 0 && x >= -10000) { for (int i = x; i <= 1; i++) p += i; } else if (x > 0 && x <= 10000) { for (int i = 1; i <= x; i++) p += i; } else p = 1; Console.WriteLine(p); //Console.ReadKey(); } } } |
| Accepted C# | Developer | 1877. Bicycle Codes | 14 May 2014 17:51 | 1 |
using System; using System.Linq; using System.Text; namespace Bicycle_Codes { class Program { static void Main(string[] args) { int c1 = int.Parse(Console.ReadLine()); int c2 = int.Parse(Console.ReadLine()); if (c1 % 2 == 0 || c2 % 2 != 0) Console.WriteLine("yes"); else if (c1 % 2 != 0 || c2 % 2 == 0) Console.WriteLine("no"); //Console.ReadKey(); } } } |
| Really? | NickSergeev[MSU MindCraft] | 1736. Chinese Hockey | 14 May 2014 05:59 | 2 |
Really? NickSergeev[MSU MindCraft] 3 Nov 2009 02:16 It is interesting to me is that problem can be solved by max flow algorithm of Ford-Falkerson, or we must use another max flow algorithm? |
| Something is wrong (Ruby) | warezoogle3 | 1877. Bicycle Codes | 14 May 2014 00:50 | 2 |
#!/usr/local/bin/ruby -w f, s = gets.split(" ").map(&:to_i) if f%2==0 || s%2!=0 puts "yes" else puts "no" end What is wrong? I'm unfortunately not know Ruby, but in my opinion f, s = gets.split("\n").map(&:to_i) because second code written at new line. |
| Help | PI-2014_Pelevin | 1785. Lost in Localization | 14 May 2014 00:33 | 2 |
Help PI-2014_Pelevin 7 May 2014 02:16 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) {
Console.WriteLine("vvedit a"); int a = int.Parse(Console.ReadLine()); if((1<=a)&&(a<=4)) Console.WriteLine("few") ; else if((5<=a)&&(a<=9)) Console.WriteLine("several"); else if ((10 <= a) && (a <= 19)) Console.WriteLine("pack"); else if ((20 <= a) && (a <= 49)) Console.WriteLine("lots"); else if ((50 <= a) && (a <= 99)) Console.WriteLine("horde"); else if ((100 <= a) && (a <= 249)) Console.WriteLine("throng"); else if ((250 <= a) && (a <= 499)) Console.WriteLine("swarm"); else if ((500 <= a) && (a <= 999)) Console.WriteLine("zounds"); else if ((1000 <= a) && (a <= 2000)) Console.WriteLine("legion");
} } } See on your selection statements. variable cannot be less then one and four at once. You maybe had in mind (1>=a)&(a<=4) |
| hehe | 大笨象=o=喳支枪 | 1037. Memory Management | 13 May 2014 12:27 | 1 |
hehe 大笨象=o=喳支枪 13 May 2014 12:27 |
| WA15 with C++ but AC with Python | lennon310 | 1133. Fibonacci Sequence | 13 May 2014 08:43 | 1 |
I used C++11 with long long type, still cannot pass #15. After changing my code to python 2.7, I got the AC. Since the input range is [-2000000000,2000000000], long long type should not suffer from overflow. Then what's the reason of WA 15? |
| 1014 Pascal WA 3? | Dior | | 13 May 2014 06:59 | 1 |
uses crt; var s:string; a,k:longint; begin read(a); k:=9; repeat if a mod k=0 then begin s:=chr(k+48)+s; a:=a div k; end else k:=k-1; until k=1; if a=1 then begin write(s); end else write('-1'); end. Edited by author 13.05.2014 06:59 Edited by author 13.05.2014 07:22 Edited by author 13.05.2014 07:23 |
| WA #30 Any hints? | Baruvka | 1199. Mouse | 12 May 2014 23:24 | 2 |
Hint #1: The mouse or the cheese can be less than 10cm from the polygons Hint #2: Be careful of your first segment from the mouse or the last segment from the cheese. If you do not check correctly, they might cross a polygon. For example, think of the case of a very thin rectangle with the long side called A and a mouse that is less than 10cm from the rectangle. You have to make sure that the mouse runs to side A not the side opposite to A. |
| Why? | without | 1820. Ural Steaks | 11 May 2014 18:27 | 2 |
Why? without 9 May 2014 02:45 if n=1(k any) we need 2 minuten, but when n=2 , k=5 we need 1 minutes. Why??? this is bug, it is imposible. if i have n = 1 and k = 10000, i need two minutes |
| help me find the bug | Иван | 1880. Psych Up's Eigenvalues | 11 May 2014 15:46 | 1 |
i found the bug Edited by author 13.05.2014 22:15 |
| WA17 | George Agapov | 1791. Uncle Styopa and Buses | 11 May 2014 14:17 | 3 |
WA17 George Agapov 31 Oct 2010 02:19 Any ideas, what's wrong? (I used greedy alogorithm) I've this test wrong too. Here's my code: #include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <set> #include <ctime> using namespace std; #define forn(i,n) for (int i = 0; i < (int)n; i++) struct bus { int l, r, type, num; friend bool operator<(const bus &bus1, const bus &bus2) { if (bus1.type != bus2.type) { return bus1.r < bus2.r; } else { return bus1.num < bus2.num; } } }; int n, m; vector<pair<int, int> > v1, v2; bus mas[300000]; multiset<bus> s; multiset<bus>::iterator iter; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); scanf("%d", &n); v1.resize(n); forn(i,n) { scanf("%d%d", &v1[i].first, &v1[i].second); v1[i].second += v1[i].first - 1; } scanf("%d", &m); v2.resize(m); forn(i,m) { scanf("%d%d", &v2[i].first, &v2[i].second); v2[i].second += v2[i].first - 1; } for (int i = 1; i <= n; i++) { mas[i].l = v1[i - 1].first; mas[i].r = v1[i - 1].second; mas[i].type = 1; mas[i].num = i; } for (int i = 1; i <= m; i++) { mas[i + n].l = v2[i - 1].first; mas[i + n].r = v2[i - 1].second; mas[i + n].type = 2; mas[i + n].num = i; } int p1 = 1, p2 = n + 1; int t = min(mas[p1].l, mas[p2].l); while ((p1 <= n && p2 <= m + n) || t <= 230000000) { while (p1 <= n && mas[p1].l <= t) { if (mas[p1].r < t) { printf("NO"); return 0; } else { s.insert(mas[p1++]); } } while (p2 <= m + n && mas[p2].l <= t) { if (mas[p2].r < t) { printf("NO"); return 0; } else { s.insert(mas[p2++]); } } iter = s.begin(); if (iter != s.end()) { if ((*iter).r < t) { printf("NO"); return 0; } else { s.erase(iter); } t++; } else { t = 230000000; if (p1 <= n) { t = min(t, mas[p1].l); } if (p2 <= n + m) { t = min(t, mas[p2].l); } if (t == 230000000) { printf("YES"); return 0; } } } printf("YES"); //printf("%.5lf", 1.0 * clock() / (1.0 * CLOCKS_PER_SEC)); } Where's bug? Re: WA17 Vit Demidenko 11 May 2014 14:17 1 1 3 2 1 4 1 2 answer is "YES" |
| be careful... | Razor | 1242. Werewolf | 10 May 2014 20:25 | 1 |
WereWolf can eat his sister or brother. But He cannot eat his father and mother, also grandfather ... so on....grandmother... |
| Error in sample | Darwin's Grove | 1917. Titan Ruins: Deadly Accuracy | 10 May 2014 20:01 | 2 |
Sample 5 4 4 1 4 1 2 Why answer is 3 2 but not 3 1 ? 2*1+1*2 <= 4 (p = 4, p — максимальная сила всплеска, которую маги ещё могут пережить, пережить тоесть включно) ??? To kill the weakest 3 coins with one spell it would have to have spell power 2, which means you get 3*2 = 6 > 4 damage reflected. |
| Please, enable Java | Sergey Filipkov | 1395. Pascal vs. C++. Version 2 | 10 May 2014 02:54 | 1 |
I strongly dislike being forced to specific languages. Java is too slow to solve the problem? OK. Why ban it? |
| 1001 - Pascal | Dior | 1001. Reverse Root | 7 May 2014 21:09 | 1 |
var n:integer; begin while not seekeof do begin read(n); write(sqrt(n):0:4); end; end. Wrong answer, but why??? |