Common Board| Show all threads Hide all threads Show all messages Hide all messages | | weak tests?... | tereshinvs | 1436. Billboard | 14 Jan 2011 01:54 | 2 | My programm search the greatest angle in x in [x1..x2] and got AC. But it's wrong. For example in test 0 3 1 1. PS Maybe i'm wrong Edited by author 13.01.2011 21:20 New tests were added. 84 authors lost AC. Edited by author 14.01.2011 02:29 | | problem with the task\ С++\ Задача 1005 | Giorgi | 1005. Stone Pile | 13 Jan 2011 23:25 | 6 | program correctly solves all problems, but for some reason the site shows that the program is wrong ... can you explain why? #include<iostream> using namespace std; int main() { double ves_k[20]; int i,num; double t,perv,vtor,res; cin>>num; if(num<1||num>20) goto vozvrat; for(i=0; i<num; i++){ cin>>ves_k[i]; if(ves_k[i]<1||ves_k[i]>10000) goto vozvrat; } if(num!=1){ for(int a=1; a<i; a++) for(int b=i-1; b>=a; b--){ if(ves_k[b-1]>ves_k[b]) { t=ves_k[b-1]; ves_k[b-1]=ves_k[b]; ves_k[b]=t; } } perv=ves_k[num-1]; vtor=ves_k[num-2]; for(i=num-3; i>=0; i--){ if(perv>=vtor) vtor+=ves_k[i]; else perv+=ves_k[i]; } res=perv-vtor; if(res<0) res=-res; } else res=ves_k[0];
cout<<res; vozvrat: return 0; } Edited by author 13.01.2011 02:22 print out your answer with end line. cout << res << endl; Greedy algorithm is wrong! You should check all 2^n situations. Greedy algorithm is wrong! You should check all 2^n situations. why the wrong ... it calculates all the results correctly, you can check yourself You can find some tests on the forum and check yourself that greedy algo is wrong. I know that the greedy algorithm is not always appropriate, but in this case, it should work | | [solved] WA #6, can't figure out what's wrong | qkthePmj | 1019. Line Painting | 13 Jan 2011 14:52 | 3 | Good time of day. I constantly get WA on test #6. Does anybody know why may this happen? Here's my code, seems to give correct answers for any correct test found in discussions: #include <stdio.h> #include <iostream> #include <map> using namespace std; typedef unsigned int uint; const uint MAX_N = 5000; const bool COLOR_BLACK = false; const bool COLOR_WHITE = true; typedef pair <uint, bool> LinePair; typedef map<uint, LinePair> TLines; TLines lines; void paint(uint c, uint d, const bool clr) { if (c == d) return; uint a, b; bool c2; if (lines.empty()) { lines[c] = LinePair(d, clr); return; } TLines::iterator i = lines.begin(); //пропускаем все отрезки, что левее нашего и не накладываются на него while (c > (i->second).first) ++i; //работаем с накладывающимися отрезками while ((d >= i->first) && (i != lines.end())) { //для удобства написания a = i->first; b = (i->second).first; c2 = (i->second).second; if (a >= c) { if (d >= b) { lines.erase(i); } else if (clr == c2) { d = b; lines.erase(i); } else { lines.erase(i); lines[d] = LinePair(b, c2); } } else { if (d >= b) { if (clr == c2) { c = a; lines.erase(i); } else { (i->second).first = c; } } else if (clr == c2) { c = a; d = b; } else { (i->second).first = c; lines[d] = LinePair(b, c2); } } ++i; } //собственно добавление заданного отрезка lines[c] = LinePair(d, clr); return; } int main() { uint n, b, e; char ch; bool clr; #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); //freopen("output.txt", "wt", stdout); #endif lines.clear(); paint(0, 1e+9, COLOR_WHITE); cin >> n; for (uint i = 0; i < n; i++) { cin >> b >> e >> ch; if (ch == 'b') clr = COLOR_BLACK; else clr = COLOR_WHITE; paint(b, e, clr); } TLines::const_iterator maxLine; uint max = 0; for (TLines::const_iterator i = lines.begin(); i != lines.end(); ++i) { if (((i->second).second == COLOR_WHITE) && ((i->second).first - i->first > max)) { max = (i->second).first - i->first; maxLine = i; } #ifndef ONLINE_JUDGE cout << i->first << '\t' << (i->second).first << '\t' << (i->second).second << endl; #endif } cout << maxLine->first << " " << (maxLine->second).first << endl; return 0; } Edited by author 05.01.2011 03:29 I've got AC. I just needed not to use iterator after erasing it. But the solution is far from optimal, I'm gonna rewrite it. AC #include <stdio.h> #include <iostream> #include <map> using namespace std; typedef unsigned int uint; const uint MAX_N = 5000; const bool COLOR_BLACK = false; const bool COLOR_WHITE = true; typedef pair <uint, bool> LinePair; typedef map<uint, LinePair> TLines; TLines lines; void paint(uint c, uint d, const bool clr) { if (c == d) return; uint a, b; bool c2; if (lines.empty()) { lines[c] = LinePair(d, clr); return; } TLines::iterator i = lines.begin(); //пропускаем все отрезки, что левее нашего и не накладываются на него while (c > (i->second).first) ++i; //работаем с накладывающимися отрезками while ((d >= i->first) && (i != lines.end())) { //для удобства написания a = i->first; b = (i->second).first; c2 = (i->second).second; if (a >= c) { if (d >= b) { i = lines.erase(i); } else if (clr == c2) { d = b; i = lines.erase(i); } else { i = lines.erase(i); lines[d] = LinePair(b, c2); } } else { if (d >= b) { if (clr == c2) { c = a; i = lines.erase(i); } else { (i->second).first = c; i++;
} } else if (clr == c2) { c = a; d = b; i++; } else { (i->second).first = c; lines[d] = LinePair(b, c2); i++; } } } //собственно добавление заданного отрезка lines[c] = LinePair(d, clr); return; } int main() { uint n, b, e; char ch; bool clr; #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); //freopen("output.txt", "wt", stdout); #endif lines.clear(); paint(0, 1e+9, COLOR_WHITE); cin >> n; for (uint i = 0; i < n; i++) { cin >> b >> e >> ch; if (ch == 'b') clr = COLOR_BLACK; else clr = COLOR_WHITE; paint(b, e, clr); } TLines::const_iterator maxLine; uint max = 0; for (TLines::const_iterator i = lines.begin(); i != lines.end(); ++i) { if (((i->second).second == COLOR_WHITE) && ((i->second).first - i->first > max)) { max = (i->second).first - i->first; maxLine = i; } #ifndef ONLINE_JUDGE cout << i->first << '\t' << (i->second).first << '\t' << (i->second).second << endl; #endif } cout << maxLine->first << " " << (maxLine->second).first << endl; return 0; } | | I get AC with 2 paths | Platto Pavel | 1220. Stacks | 13 Jan 2011 11:35 | 2 | First, very stupied method: used just 2 arrays for A and B values, 0.609s, 673KB. Second, some hint: used multi-stack and for pointers at next element used unsigned short, 0.031s, 677KB. Sorry, for bad english:-) I used 2 arrays for A and B values and O(n) algorithm | | C/C++ malloc function doesn`t work | atamachi | | 13 Jan 2011 00:12 | 3 | Hello, I try to solve problem 1209 with allocating memory, but i receive compilation error. --------------------------------------------------------- e2c33114-a1cd-488e-b50b-9a2950afaee7 e2c33114-a1cd-488e-b50b-9a2950afaee7(8) : error C2143: syntax error : missing ';' before 'type' e2c33114-a1cd-488e-b50b-9a2950afaee7(19) : error C2065: 'AA' : undeclared identifier e2c33114-a1cd-488e-b50b-9a2950afaee7(19) : error C2109: subscript requires array or pointer type e2c33114-a1cd-488e-b50b-9a2950afaee7(24) : error C2065: 'AA' : undeclared identifier e2c33114-a1cd-488e-b50b-9a2950afaee7(24) : error C2109: subscript requires array or pointer type e2c33114-a1cd-488e-b50b-9a2950afaee7(30) : error C2065: 'AA' : undeclared identifier e2c33114-a1cd-488e-b50b-9a2950afaee7(30) : error C2109: subscript requires array or pointer type e2c33114-a1cd-488e-b50b-9a2950afaee7(32) : error C2065: 'AA' : undeclared identifier e2c33114-a1cd-488e-b50b-9a2950afaee7(32) : warning C4022: 'free' : pointer mismatch for actual parameter 1 --------------------------------------------------------- Code example: --------------------------------------------------------- #include <stdio.h> #include <malloc.h> int main() { int N; scanf("%d", &N); int *AA = (int *)malloc(N*sizeof(int)); ... ... ... free(AA); return 0; } --------------------------------------------------------- What the matter ? Thank you for answers. Edited by author 12.01.2011 23:44 This is correct code for C++, not for C, because when using C compiler, only forward var declarations are permited { int N = 0; int* AA = NULL; // ... AA = (int*)malloc(..); // etc. } This is correct code for C++, not for C, because when using C compiler, only forward var declarations are permited { int N = 0; int* AA = NULL; // ... AA = (int*)malloc(..); // etc. } I receive this kind of errors again... Compilation errors. ------------------ 311e64be-7d0c-42db-86d6-9276eb18480e(8) : error C2143: syntax error : missing ';' before 'type' 311e64be-7d0c-42db-86d6-9276eb18480e(9) : error C2065: 'AA' : undeclared identifier 311e64be-7d0c-42db-86d6-9276eb18480e(9) : warning C4047: '=' : 'int' differs in levels of indirection from 'int *' 311e64be-7d0c-42db-86d6-9276eb18480e(20) : error C2065: 'AA' : undeclared identifier 311e64be-7d0c-42db-86d6-9276eb18480e(20) : error C2109: subscript requires array or pointer type 311e64be-7d0c-42db-86d6-9276eb18480e(25) : error C2065: 'AA' : undeclared identifier 311e64be-7d0c-42db-86d6-9276eb18480e(25) : error C2109: subscript requires array or pointer type 311e64be-7d0c-42db-86d6-9276eb18480e(31) : error C2065: 'AA' : undeclared identifier 311e64be-7d0c-42db-86d6-9276eb18480e(31) : error C2109: subscript requires array or pointer type 311e64be-7d0c-42db-86d6-9276eb18480e(33) : error C2065: 'AA' : undeclared identifier 311e64be-7d0c-42db-86d6-9276eb18480e(33) : warning C4022: 'free' : pointer mismatch for actual parameter 1 ------------------ Full code ------------------ #include <stdio.h> #include <malloc.h> int main() { int total_zero, count_zero, i, N, K, s; scanf("%d", &N); int* AA = NULL; AA = (int*)malloc(N*sizeof(int)); s = 0; for( ; N > 0; N--){ scanf("%d", &K); total_zero = count_zero = i = 0; while( 1 ){ i++; if(total_zero == count_zero){ count_zero = 0; total_zero++; if(i == K){ AA[s++] = 1; break; } } if(i == K){ AA[s++] = 0; break; } count_zero++; } } for(i = 0; i < s; i++) printf("%d ", AA[i]); fputc('\n', stdout); free(AA); return 0; } ------------------ error C2143: syntax error : missing ';' before 'type' It is very strange. | | Only some hours to solve it ! I think it's simple problem. Although at the first sight, it's likely hard. | Phan Hoài Nam (Harvey Nash) | 1189. Pairs of Integers | 12 Jan 2011 15:27 | 1 | You can go from last digit to the first (the leftmost digit to the rightmost digit). For example : 302 Considering 2 : There are some possibilities: 0 + 2, 1 + 1, 2 + 0, 6 + 6, 5 + 7 ... (first operant is of the larger number, second operant is of the smaller number). Considering 0 : For each possibilities, you try to find out some possibilities that can be combined to produce 0 : 0 + 0... You can try any combinations to produce 0 if two operants used to produce 2 is equal, if they are different, you only have an only way, it reduce very much calculations). Considering 3 : The last digit, you can stop here and consider whether you have achieved a solution. | | There is one useful test here | Burunduk1 | 1037. Memory Management | 12 Jan 2011 14:50 | 4 | It helped me to get AC. Test: 1 + 1 + 1 + 10 . 2 11 . 3 600 + 601 . 1 609 . 2 611 . 3 Right answer: 1 2 3 + + 4 - + - this is giving correct output for me but i am failing in test case 2 why ? can u help this is giving correct output for me but i am failing in test case 2 why ? can u help Thank you very much! I can't get AC without it,either~ | | Multiple threads | Evgeniy++ | | 11 Jan 2011 20:12 | 2 | Hello! Is it allowed to use multiple threads in solutions? Thank you. Also it would be nice if You write hardware configuration of testing server. Thanks in advance. | | WA#10 | ZiV | 1222. Chernobyl’ Eagles | 11 Jan 2011 11:48 | 5 | WA#10 ZiV 10 Jan 2006 00:14 Edited by author 10.01.2006 12:58 :))))))))) ACM.Krupko_Victor[Ivanovo SPU] 10 Jan 2006 01:06 n=3000 answer 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 1322070819480806636890455259752144365965422032752148167664920368226828597346704899540778313850608061963909777696872582355950954582100618911865342725257953674027620225198320803878014774228964841274390400117588618041128947815623094438061566173054086674490506178125480344405547054397038895817465368254916136220830268563778582290228416398307887896918556404084898937609373242171846359938695516765018940588109060426089671438864102814350385648747165832010614366132173102768902855220001 I pass your test, but i can't pass test 10. | | WA1 on Java. | Muravjev Slava [Samara SAU] | 1027. D++ Again | 11 Jan 2011 02:36 | 1 | Please, give me tests or hints about test 1!!! Edited by author 11.01.2011 16:16 | | Thanks to Author! | Oracle[Lviv NU] | 1519. Formula 1 | 10 Jan 2011 20:44 | 1 | I enjoyed solving that problem! Very interesting, thanks a lot. P.S. Answer for empty grid 12x12 = 1076226888605605706 | | Weak tests | Zayakin Andrey[PermSU] | 1416. Confidential | 10 Jan 2011 13:28 | 2 | Weak tests Zayakin Andrey[PermSU] 7 Aug 2010 21:59 My O(M*M*log(N)) solution passed. New tests were added. 40 authors lost AC. | | Show the input with the WA result | Lolmaker | | 10 Jan 2011 03:44 | 1 | Can you show us Input with the Wrong Answer result? | | Be careful, the last charactor is '.' not ',', this reason lead to 2 WA~ | ZLqiang | 1008. Image Encoding | 9 Jan 2011 15:19 | 2 | #include <cstdio> #include <cassert> #include <cctype> #include <utility> #define x first #define y second const int MAX = 16; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; int N; bool brd[MAX][MAX]; int ref[256]; int main () { char line[16]; gets (line); static std::pair <int, int> q[MAX * MAX]; int p3 = 0; int a, b; int i, j; ref[(int)'R'] = 0; ref[(int)'T'] = 1; ref[(int)'L'] = 2; ref[(int)'B'] = 3; if (sscanf (line, "%d %d", &a, &b) == 2) { q[p3++] = std::make_pair (a, b); brd[a][b] = 1; for (i = 0; i < p3; ++i) { gets (line); for (j = 0; isalpha (line[j]); ++j) { assert (line[j] == 'R' || line[j] == 'T' || line[j] == 'L' || line[j] == 'B'); brd[q[i].x + dx[ref[(int)line[j]]]][q[i].y + dy[ref[(int)line[j]]]] = 1; q[p3++] = std::make_pair (q[i].x + dx[ref[(int)line[j]]], q[i].y + dy[ref[(int)line[j]]]); } } assert (line[j] == '.'); printf ("%d\n", p3); for (i = 1; i < MAX; ++i) for (j = 1; j < MAX; ++j) if (brd[i][j]) printf ("%d %d\n", i, j); } else { N = a; for (i = 0; i < N; ++i) { scanf ("%d %d\n", &a, &b); if (i == 0) q[p3++] = std::make_pair (a, b); else brd[a][b] = 1; } printf ("%d %d\n", q[0].x, q[0].y); for (i = 0; i < p3; ++i) { for (j = 0; j < 4; ++j) { if (brd[q[i].x + dx[j]][q[i].y + dy[j]]) { putchar ("RTLB"[j]); brd[q[i].x + dx[j]][q[i].y + dy[j]] = 0; q[p3++] = std::make_pair (q[i].x + dx[j], q[i].y + dy[j]); } } if (i == N - 1) putchar ('.'); else putchar (','); puts (""); } } return 0; } | | To admins. C# is broken. | Progbeat | | 9 Jan 2011 05:34 | 4 | Any program written on C# gets OLE (unless it gets CE). Fixed Vladimir Yakovlev (USU) 9 Jan 2011 05:34 | | All the test(To 5) | Fadeev.E.V | | 8 Jan 2011 22:18 | 1 | Can explain please that tests - 1, 2, 3, 4, 5 mean.То there is what childbirth of errors they reveals. | | Maybe it can help someone | Yevgeniy | 1004. Sightseeing Trip | 7 Jan 2011 18:51 | 2 | 5 6 1 5 1 3 5 100 3 4 2 2 4 1 4 5 10 1 2 1 Answer: 1 2 4 5 thank you very much, I got an AC | | Problem 1034 "Queens in Peaceful Positions". New tests were added. (+) | Sandro (USU) | 1034. Queens in Peaceful Positions | 7 Jan 2011 00:24 | 1 | 50 authors lost AC after rejudge. | | Good problem. Use only integer calculations | Серовиков Андрей | 1679. Scrooge's Tower | 6 Jan 2011 17:38 | 5 | I tried to solve with some float precisions but it was always WA. Then it was written using only integer calculations and AC. But integer solution really nice ;) I think that integer method is nice because it mathematically easy proved Float method has only timus-Ac verification and there for less nice. I tried to find regorious analysis of some float algo based on computer float system theory but it is rather difficult. I totally agree - very interesting problem with integer solution. | | I CAN"T UNDERSTAND THIS PROBLEM | Micheal Jackson | 1538. Towers of Guard | 6 Jan 2011 15:51 | 1 | So, if the pigeon is black or white, how does this work? Edited by author 06.01.2011 15:52 |
|
|