Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Problem 1820 Ural Steaks has been rejudged | Vladimir Yakovlev (USU) | 1820. Ural Steaks | 24 Oct 2016 12:31 | 1 | New tests have been added to the problem, all accepted solutions have been rejudged. 490 authors have lost their AC. | | What count of pattern for n=36? | Scalar | 1708. Sum of Digits 2 | 23 Oct 2016 18:56 | 5 | Edited by author 17.06.2009 19:29 I also get 47062 and use 1500+ms 85000K in codeforces custom test, how to optimize memory? YES Accepted memory is too hard... Edited by author 23.10.2016 18:54 Edited by author 23.10.2016 18:54 I hope admin can decrease the Time limit to 1s, to encourage me continue to optimise time. | | Test case for Wrong Answer 1 | j.n.j.d.1 | 1297. Palindrome | 23 Oct 2016 15:25 | 1 | Can anyone provide test case for WA#1, please? | | Simple Solution | Shaft | 1149. Sinus Dances | 22 Oct 2016 16:42 | 2 | #include <iostream> #include <cstdlib> #include <string> using namespace std; string S, A; unsigned short An = 1; bool negative = true; void get_next_A(); void get_S(unsigned short); int main() { unsigned short input_n; cin >> input_n; get_S(input_n); cout << S << endl; return 0; } void get_next_A() { if(An == 1) A = "sin(1)"; else { A.erase(A.size() - An + 1, An); if(negative) A += "-sin("; else A += "+sin("; char buffer[5]; itoa(An, buffer, 10); A += buffer; for(unsigned short j = 0; j < An; ++j) A += ")"; negative = !negative; } ++An; return; } void get_S(unsigned short n) { char _buffer[10]; for(unsigned short i = 0; i < n - 1; ++i) S += '('; for(unsigned short i = n; i > 0; --i) { get_next_A(); itoa(i, _buffer, 10); S += A; S += '+'; S += _buffer; if(i != 1) S += ')'; } return; } You can make it simpler :) For example, here is the function generating sine expressions: string get_sine_expression(int x, int n) { if (x == n) return "sin(" + to_string(x) + ")"; char sign = x & 1 ? '-' : '+'; return "sin(" + to_string(x) + sign + get_sine_expression(x + 1, n) + ")"; } | | Whats problem? C++ | TIU_Sarexer | 1068. Sum | 21 Oct 2016 19:00 | 2 | #include <iostream> using namespace std; int main() { int n,res=0; cin >> n; if (n < 0) { n = n*-1; int *arr; arr = new int[n+2]; arr[0] = 1; for (int i = 1; i < n+2; i++) { arr[i] = arr[i - 1] - 1; } for (int i = 0; i < n+2; i++) { res = res + arr[i]; } cout << res; } else if(){ int *arr; arr = new int[n]; arr[0] = 1; for (int i = 1; i < n; i++) { arr[i] = arr[i - 1] + 1; } for (int i = 0; i < n; i++) { res = res + arr[i]; } cout << res; } return 0; } n = n*-1; ? arr[i] = arr[i - 1] - 1; ? -10000.....-1 0 1 | | Что не так? | Kovalyshyn Artur | 1068. Sum | 21 Oct 2016 18:40 | 4 | program Suma; var a,b,e:integer; begin read(a); b:=1; if a<0 then e:=((1+a) div 2)*(((a-1)div((b-1)-1))+1) else e:=(a*(a+1)) div 2; writeln(e); end. import java.util.Scanner; public class P { public static void main(String[] args) { Scanner input = new Scanner(System.in); int a = input.nextInt(); int b = 1; if (a>-10000) if (a < 10000) { if (a >= 1) { int e = (a * (a + 1)) / 2; System.out.println(e); } if (a <= -1) { int d = ((1 + a) / 2) * ((a - 1) / ((b - 1) - 1) + 1); System.out.println(d); } if (a<1) if (a>-1) { System.out.print(a+1); } } } } я уже всё зделал, что они просили. И всё равно не идёт( Edited by author 21.10.2016 18:08 Edited by author 21.10.2016 18:37 check 2. Prints reply twice. Edited by author 21.10.2016 18:47 Edited by author 21.10.2016 18:52 | | Что не так? Помогите пожалуйста. | awicone | 1068. Sum | 21 Oct 2016 16:59 | 2 | var i,n,q,h:integer; k:real; begin q:=0; read(n); h:= 10000; if (n <= h) and (n >= -h) then begin if n>0 then begin k:= ((1+n)/2)*n; writeln(k); end; if n=0 then begin k:=0+1; writeln(k); end;
if n<0 then begin for i:= 1 downto n do inc(q); k:= ((1+n)/2)*q; writeln (k); end; end; end. формула для від'ємних чисел не підходить там така має бути(по моєму): ((1 + a) / 2) * ((a - 1) / ((b - 1) - 1) + 1) Edited by author 21.10.2016 16:59 | | I believe this judge is absurd | fireyyouth | 1196. History Exam | 21 Oct 2016 13:02 | 5 | I tried binary search, harsh table, got TLE. then I thought using direct mapping table could get MLE, but never TLE, so i tried it, still TLE!!!tell me how could this code get TLE. #include <iostream> using namespace std; char a[1000000001]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { int j; cin >> j; a[j] = 1; } int m; cin >> m; int cnt= 0; for (int i = 1; i <= m; ++i) { int j; cin >> j; cnt += a[j]; } cout << cnt; } To start with, 1 billion might be a bit too huge of a number. Try 3 zeroes less maybe. Insert this string: int main() { ios::sync_with_stdio(false); // It will speed up reading process } It doesn't (significantly) speed up Visual C++, as for me. Using C-style IO (printf/scanf) is more predictable. | | please help me to find out error! | alcidewww | 1000. A+B Problem | 21 Oct 2016 11:14 | 2 | #include <stdio.h> int main(){ int a, b,c; scanf_s("%d",&a); scanf_s("%d",&b); c = a + b; return 0; } //the result is wrong answer,I want to ask why?Can you help me fix it? You don't have a sense of output statement. #include <stdio.h> int main () { int a, b, c; scanf("%d", &a); scanf("%d", &b); c = a + b; printf("%d", c); return 0; } | | in case of WA 6 | Arseny Babushkin (aytel) | 2014. Zhenya moves from parents | 20 Oct 2016 20:41 | 1 | check whether months have higher priority than days in your program Edited by author 20.10.2016 20:42 | | Accepted | Shen Yang | 1524. Men in Black | 20 Oct 2016 05:53 | 1 | big simulation spend one day+ and 700+ lines without seeing test data | | Evil problem | Paul Komarnytskyy | 1873. GOV Chronicles | 20 Oct 2016 00:55 | 6 | It's not a programming challenge. It's more of "Can you read me whole?" challenge. Kinda reminds License agreement... Moreover, it was rejudged recently. And I have no idea now where is mistake. My AC was in 2012 :D nikita.seleznev, we have addition 1 game & 2 new peoples. They added one more paragraph. - In this paragraph there is a description of a new contest, and two new teammates: "The numbers of Timothée and Alexandre are 12 and 13 respectively." They only took part in that one last contest. This also meant that Vadik has one new contest to add to hes experience. As we can read in the description "Vadik — 1", "And a number one participated in 21 contests." That's why results of test #1 changed today from 20 to 21 ;) | | В чем, собственно, условие, если нет логики? | Riot | 2001. Mathematicians and Berries | 20 Oct 2016 00:17 | 2 | В примере, в результате написано "1 1", однако в вычислениях мы видим "1 2 - 2 1 - 0 3". Откуда, спрашивается, взялась еще одна единица? Каждый собрал по 1 кг, при пересыпаниях туда-сюда получаем 0кг и 2кг и наоборот. Объясните нормально условие Baskets weight something. Weight isn't fixed, isn't the same and should be found to receive program solution. In the example first basket weights 0 kg (plastic packet?). Second basket weights 1 kg. Edited by author 20.10.2016 14:58 | | why for k=8, N=15. N=11 looks perfectly correct. | Vedsar Kushwaha | 1673. Admission to Exam | 19 Oct 2016 19:42 | 2 | If K=8, i.e 1,2,3,4,5,6,7,8 students. Now, each student has to sit for at least 1 lab of each professor. For N=11, Students 1 will sit in all labs, hence qualified for exam. Students 2 will sit in labs: 2,4,6,8,10,12,14,16,18,20,22. hence qualified for exam. (At least 1 lab of all Prof covered) Students 3 will sit in labs: 3,6,9,12,15,18,21,24,27,30,33 labs. hence qualified for exam. (At least 1 lab of all Prof covered) . . . Similarly Student 8 will sit in 8,16,.....,88 labs, hence qualified for exam. (At least 1 lab of all Prof covered) Please help, where I'm wrong. Just got it. N=11 will violate "exactly K students" condition. For N=11, there will be 10 students who can qualify for exams. | | If N = 0 Q = -1 or Q = 0? | Orventro | 1014. Product of Digits | 18 Oct 2016 21:30 | 2 | If N = 0 Q = -1 or Q = 0? | | WA4, C#, Please help to find a mistake | Michael | 1100. Final Standings | 18 Oct 2016 20:04 | 3 | I use LINQ to sort this sequence, it works pretty well on all tests i found. Any ideas why it works wrong on test 4? using System; using System.Linq; namespace Таблица_результатов { class Program {
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] lines = new string[n]; for (int i = 0; i < n; i++) { lines[i] = Console.ReadLine(); }
var a = lines .Select(x => x.Split()) .ToArray() .OrderByDescending(x => x[1]);
foreach (var x in a) { Console.WriteLine(x[0] + " " + x[1]); } } } } Looks like you are sorting by M string representation Try test 3 1 1 2 100 3 2 Yeah, you are right, thanks for answering, now it passes the test. P.S. Fixed by replacing .OrderByDescending argument with (x => int.Parse(x[1])) if someone's interested. | | Accepted | Shen Yang | 1374. Misere | 18 Oct 2016 04:42 | 1 | another easy 10000+ problem..haha | | for WA 26 | Arseny Babushkin (aytel) | 1684. Jack's Last Word | 17 Oct 2016 20:10 | 1 | for WA 26 Arseny Babushkin (aytel) 17 Oct 2016 20:10 don't use hashes with modulo = 2^32, change it to 10^9 + 7 | | WA#52 | Babies | 1428. Jedi Riddle | 16 Oct 2016 19:44 | 2 | WA#52 Babies 20 Apr 2013 22:56 Hi, i have problem with WA#52, I used long long and test 1 1 32 => accept. This's my code : #include <iostream> using namespace System; using namespace std; long long func( long long x , int po ); void main() { long long a,b,c,y,k,x,n,m; cin>>a>>b>>c; k = (c-1)/a; m = (c-1)/b; x = func( k ,2 ); y = func( m , 2 ); printf("%lld\n%lld\n2",x,y); system("pause"); } long long func( long long x , int po ) { long long temp=2; for( int i=1; i<x; i++ ) { temp *= po; } return temp; } Re: WA#52 Combatcook [YarSU] 🐸 16 Oct 2016 19:44 Hi, I had WA 52 too, these tests helped me: 1) 1 1 1 2) 5 10 1 Edited by author 16.10.2016 19:50 | | Algorithm | monsky | 1002. Phone Numbers | 16 Oct 2016 17:47 | 1 | It's not so interesting to publish ready code, but for those who stuck on this problem the following algorithm could be useful: 1. First of all, build generator, that will generate random tests with specified phone number length and number of words. It will helpful, since you don't know, which tests are runned when you send you code for check. 2. Convert your words to digits and remove those of them that aren't contained in phone number. Also remove duplications that can appear after this converting. During this process build dictionary that will contain converted word as a key, and original word as a value. Last one will be needed to output the result. 3. Sort converted words by length in descendent order. 4. Take every converted word and find all its inclusions to the phone number. Build dictionary that will contain found index as key and list of converted words as value. 5. Now use recursive function which initially will get index=0 as argument, find all words from dictionary for the index and loop them, taking their length to get next index. If next index equals phone number length, you found one of the solutions. 6. Optimize the function to eleminate redundant calls. I mean, on specific step you can check if the next searched solution is expected to be better than found one or not. I'm not sure that this algorithm is the best, but at least I got "accepted" on C# with 600 ms performance. |
|
|