Common Board| Show all threads Hide all threads Show all messages Hide all messages | | WA#4 | Giorgi | 1423. String Tale | 19 Nov 2016 03:00 | 1 | WA#4 Giorgi 19 Nov 2016 03:00 A can't understand what's the problem and why I don't pass it. Help me, please. | | What is 56th test | Mukhammadali | 2011. Long Statement | 18 Nov 2016 20:52 | 1 | | | Can somebody help me, please | Abbos | 1931. Excellent Team | 18 Nov 2016 20:25 | 3 | What's the meaning of the question ? I tried to get it but in vain, even the test unclear for me I'll explain the test. 6 2 5 3 4 1 9 The first one is chosen as current candidate, and has 2 disadvantages. Then, he is compared with 2nd pirate (5 disadvantages), 3rd (3), 4th (4), 5th (1). When comparing with 5th pirate, we see that he has less disadvantages (1) than current candidate (2). So he becomes the current candidate. And then we finally compare him with last pirate (9 disadvantages). In the end, 1st pirate with 2 disadvantages was compared to 2nd, 3rd, 4th, 5th — compared 4 times; 2nd pirate with 5 disadvantages was compared to 1st — compared 1 times; 3rd pirate with 3 disadvantages was compared to 1st — compared 1 times; 4th pirate with 4 disadvantages was compared to 1st — compared 1 times; 5th pirate with 1 disadvantages was compared to 1st, 6th — compared 2 times; 6th pirate with 9 disadvantages was compared to 5th — compared 1 times; Out of all the pirates, the 1st one has the most compare times — 4. Thus, we output 1 — the index of a pirate who was compared most times. But, if several pirates were compared the same amount of times — say, if 5th one was also compared 4 times (if there were 2 more pirates in input) — then both answers "1" or "4" would be correct in this case. Is this any clearer? | | can anyone explain the problem description please? | Shen Yang | 1388. Photo | 18 Nov 2016 16:48 | 1 | thanks I want to know what's the task of this problem. | | An interesting way of coding it | Egor | 2010. Sasha the Young Grandmaster | 18 Nov 2016 02:11 | 1 | There is an interesting way to code it. For each piece we can have a function like this: pair<string, int> get_king(int n, int x0, int y0) { int cnt = 0; for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <= 1; dy++) if (dx != 0 || dy != 0) { int x = x0 + dx; int y = y0 + dy; cnt += (x >= 1 && x <= n && y >= 1 && y <= n); } return { "King", cnt }; } In the main code we just do the following loop: for (auto get : { get_king, get_knight, get_bishop, get_rook, get_queen }) { auto res = get(n, x, y); cout << res.first << ": " << res.second << endl; } After that the function for queen look very easy: pair<string, int> get_queen(int n, int x0, int y0) { int cnt = get_rook(n, x0, y0).second + get_bishop(n, x0, y0).second; return { "Queen", cnt }; } If you have any ideas on how to code it better, please write them here :) | | WA9, I'm check all forum topic, all test success, but WA9. Please!!! | phfaster | 1005. Stone Pile | 17 Nov 2016 19:04 | 1 | My tests (N, Array, Answer): [8, '6 7 9 13 18 24 31 50', 0], [5, '5 5 4 3 3', 0], [5, '3 3 4 5 5', 0], [1, '1', 1], [1, '2', 2], [6, '1 4 5 6 7 9', 0], [5, '5 8 13 27 14', 3], [5, '5 4 3 3 3', 0], [5, '11 10 8 7 6', 0], [6, '1 4 5 6 7 9', 0], [6, '9 7 6 5 4 1', 0], [7, '1 2 3 4 5 6 6', 1], [3, '1 1 5', 3], [6, '1 2 3 4 100 100', 0], [5, '5 8 13 14 15', 1], [5, '4 6 6 7 9', 0], [7, '36 25 12 10 8 7 1', 1], [6, '101 51 51 3 2 2', 0], [6, '1 4 5 6 7 9', 0], [4, '1 3 9 27', 14], [6, '6 6 5 4 3 2', 0], [20, '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20', 0] All tests = True. What I do wrong? Edited by author 17.11.2016 19:27 Edited by author 17.11.2016 20:03 | | K based numbers, containing N digits modulo M | sleepwalker | 1013. K-based Numbers. Version 3 | 17 Nov 2016 18:22 | 1 | What does it mean? For example if K = 10, N = 3, M = 112 correct numbers are 101 102 103 104 105 106 107 108 109 110 111 Is it right? Thanks. Edited by author 17.11.2016 18:22 | | WA8 and WA12 | 💻Evgeny Nemtsev [UrFU]` | 1971. Graphics Settings | 17 Nov 2016 11:44 | 1 | WA8 - all options are off and <10fps WA12 - "Perfect" when >=60fps, NOT >60fps | | Can someone explain me how to solve this problem. | Sanatbek_Matlatipov | 2067. Friends and Berries | 16 Nov 2016 17:57 | 2 | Tags: geometry *hint hint* | | Help error | Leonid322S | 1293. Eniya | 16 Nov 2016 16:49 | 2 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { int N = Convert.ToInt32(Console.ReadLine()); int A = Convert.ToInt32(Console.ReadLine()); int B = Convert.ToInt32(Console.ReadLine()); if (N >= 1 && 100 >= N) if (A >= 1 && 100 >= A) if (B >= 1 && 100 >= B) { Console.WriteLine(N * A * B * 2); } } } } 1) Here is task fragment: "The only line contains integers...." You are reading 3 lines. 2) if (N) if (A) if (B) {...} - else what? Any difference how exactly your program fail in "else" case? I think you should skip parameters check or fail in some specific way - visible and different from regular mistake. Edited by author 16.11.2016 16:53 | | there are about 3*10^7 states not consider the position of player. | Shen Yang | 1589. Sokoban | 15 Nov 2016 13:12 | 2 | if consider the position of player there are about 7.5*10^8(upper_bound),state, we can come up some idea to compact the states,and use a huge array instead of hash_table to prevent the duplication of states this may far speed up your program Edited by author 15.11.2016 13:02 Edited by author 15.11.2016 13:02 maybe for every 3*10^7 possible states,we can compact the postion of player and record the number of connected place,and use twice bfs search I think that will reduce the number of states we must store... | | Wrong Answer #2 | nushrat | 1086. Cryptography | 15 Nov 2016 12:48 | 2 | I have been stuck on this test 2 for a while now. I gave up then came back, but still don't know what I need to change. Here is my solution, I used 'sieve of eratosthenes' to get out the primes. Please help me out. Should I change my input range for array. #include <iostream> #include <math.h> using namespace std; int main() { __int64 n; cin >> n; __int64 *input_list = new __int64[n]; //__int64 *primes = new __int64[15000]; long int primes[20000] = { 0 };
// input the numbers for (int i = 0; i < n; i++) { cin >> input_list[i]; } // Let A be an array of Boolean values, indexed by integers 2 to n, //initially all set to true. //for i = 2, 3, 4, ..., not exceeding √n: //if A[i] is true: //for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n : //A[j] := false
//Output: all i such that A[i] is true. long int a[20000] = { 0 };
for (long int i = 2; i <= 20000; i++) { if (a[i] == 0) { for (long int j = i * i, c=1; j < 20000; j +=i, c++) { a[j] = 1; } } //cout << a[i] << ends; } for (long int i = 2, p=0; i <= 20000; i++) { if (a[i] == 0) { //cout << i << ends; primes[p] = i; p++; } else { continue; } } for (int i = 0; i < n; i++) cout << primes[input_list[i] - 1] << endl; return 0; } Edited by author 15.11.2016 09:33 For a test 5 2260 2261 2262 2263 2264 your program gives 19991 19993 19997 0 0. I tried an "obvious" fix, changing all 20000's into 200000's, to fit for 1 15000 test, but got a stack overflow error. I don't want to look too deep into it, so i'd rather suggest going an easy way. Just make IsPrime(int value), which would determine if the number is prime or not, then for i=1..infinity, add i into your array if it's prime, and stop after adding 15000 numbers. After that it should be easy. | | propose to rejudge | Serhiy Ivanov | 1548. Sakura and Statistics | 15 Nov 2016 07:23 | 3 | I was bit confused to obtain accepted. I applied my solution to test straightforward approach and obtain TLE but i'm not. With next example i would defenitely obtain TLE: 50 50 00000000000000000000000001111111111111111111111111 00000000000000000000000011111111111111111111111111 00000000000000000000000111111111111111111111111111 00000000000000000000001111111111111111111111111111 00000000000000000000011111111111111111111111111111 00000000000000000000111111111111111111111111111111 00000000000000000001111111111111111111111111111111 00000000000000000011111111111111111111111111111111 00000000000000000111111111111111111111111111111111 00000000000000001111111111111111111111111111111111 00000000000000011111111111111111111111111111111111 00000000000000111111111111111111111111111111111111 00000000000001111111111111111111111111111111111111 00000000000011111111111111111111111111111111111111 00000000000111111111111111111111111111111111111111 00000000001111111111111111111111111111111111111111 00000000011111111111111111111111111111111111111111 00000000111111111111111111111111111111111111111111 00000001111111111111111111111111111111111111111111 00000011111111111111111111111111111111111111111111 00000111111111111111111111111111111111111111111111 00001111111111111111111111111111111111111111111111 00011111111111111111111111111111111111111111111111 00111111111111111111111111111111111111111111111111 01111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111110 11111111111111111111111111111111111111111111111100 11111111111111111111111111111111111111111111111000 11111111111111111111111111111111111111111111110000 11111111111111111111111111111111111111111111100000 11111111111111111111111111111111111111111111000000 11111111111111111111111111111111111111111110000000 11111111111111111111111111111111111111111100000000 11111111111111111111111111111111111111111000000000 11111111111111111111111111111111111111110000000000 11111111111111111111111111111111111111100000000000 11111111111111111111111111111111111111000000000000 11111111111111111111111111111111111110000000000000 11111111111111111111111111111111111100000000000000 11111111111111111111111111111111111000000000000000 11111111111111111111111111111111110000000000000000 11111111111111111111111111111111100000000000000000 11111111111111111111111111111111000000000000000000 11111111111111111111111111111110000000000000000000 11111111111111111111111111111100000000000000000000 11111111111111111111111111111000000000000000000000 11111111111111111111111111110000000000000000000000 11111111111111111111111111100000000000000000000000 rejudge me please, I also get AC using brute_force and can't pass this test case Edited by author 15.11.2016 07:21 now 13 problems with 10W+ rating... | | What's wrong with my code? Че не так ? (C++) | Zalkar | 1001. Reverse Root | 14 Nov 2016 16:26 | 2 | #include<iostream> #include<iomanip> #include<cmath> using namespace std; int main() { long long n,i=0,c=0; double a[100001]; while(cin>>n){ a[i]=sqrt(n); i++; c++; } for(int i=c-1; i>=0; i--) cout<<fixed<<setprecision(4)<<a[i]<<endl; system("pause"); return 0; } The size of the input stream does not exceed 256K | | Please send some examples | Nataraj | 2024. Adventure Time | 14 Nov 2016 09:52 | 4 | Could somebody who solved this problem send some examples of tests and solutions? I thought that I wrote a correct algorithm, that summarise number of stones of each type, then sort it and then check how many permutations of the last one that makes it equal to K, there is and calculate a number of possibilities. But I get error on Test 3. Or may be I did not understood the task, I found the bug, but now I get wrong answer for test 26 Finally solved it. The last bug was to find a function that calculates factorial coefficients (ncr) without going to big numbers. What is the principle of this function? | | TEST #10 | James Chan | 1014. Product of Digits | 12 Nov 2016 22:59 | 2 | Anybody can help me with TEST #10. Just give me an example Thank you very much. 222 ans is--> -1 bcuz 222/6= 37 ;but 37 is prime so ans -1 | | No subject | Andrey | 1493. One Step from Happiness | 12 Nov 2016 19:26 | 1 | #include <iostream> long int a,b,c,d,e,f,n,z,x,a1,a2; using namespace std; void main() { cin >>a; n=a%10; f=a%100; f=f/10; e=a%1000; e=e/100; d=a%10000; d=d/1000; c=a%100000; c=c/10000; b=a%1000000; b=b/100000; if ((n==9)||(f==9)||(e==9)) { z=(e+f+n)+1%10; } else { z=e+f+n; } if ((d==9)||(c==9)) { x=(b+c+d)+1%10; } else { x=b+c+d; } a1=z-x; a2=x-z; if ((a1==1)||(a2==1)) { cout <<"Yes"; } else { cout <<"No"; } } | | A few tests that helped me to find an error. | Victor Barinov (TNU) | 1058. Chocolate | 12 Nov 2016 02:53 | 3 | 4 0 0 1 0 0 1 -1 1 0.7071 3 0 0 1 0 0 1 0.6436 3 -1 0 1 0 0 1 0.9102 Thank you. But... C:\Casual\Task1058>task1058.exe <test12.txt 0.7071 C:\Casual\Task1058>task1058.exe <test13.txt 0.6436 C:\Casual\Task1058>task1058.exe <test14.txt 0.9102 I can hardly ever understand anything. My program cannot pass test #3. | | Tests | Islom(TUIT Urgench) | 1425. Queen 2 | 11 Nov 2016 18:24 | 1 | Tests Islom(TUIT Urgench) 11 Nov 2016 18:24 Test#1 3 3 1 2 3 ans:27 Test#2 2 6 1 3 ans:36 Test#3 3 6 3 4 5 ans: 180 Test#4 1 5 3 ans:5 Test#5 1 2 1 ans:1 Test#6 3 2 1 2 2 ans:4 | | JAVA, plz help | fletcher6847 | 2002. Test Task | 11 Nov 2016 13:00 | 2 | import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Timus2002 { public static void main(String[] args) { Map<String, String> map = new HashMap<>(); Scanner sc = new Scanner(System.in); String[] s = new String[105]; ArrayList<String> logged = new ArrayList<>(); int n = Integer.parseInt(sc.nextLine()); for (int i = 0; i < n; i++) { s[i] = sc.nextLine(); } for (int i = 0; i < n; i++) { String[] mas = s[i].split(" "); if(mas[0].equals("register")){ if(map.containsKey(mas[1])){ System.out.println("fail: user already exists"); continue; } map.put(mas[1], mas[2]); System.out.println("success: new user added"); } String login = mas[1]; if(mas[0].equals("login")){ String pass = mas[2]; if(!map.containsKey(login)) { System.out.println("fail: no such user"); continue; } String value = map.get(login); if(!value.equals(pass)) System.out.println("fail: incorrect password"); if(value.equals(pass)) { if (!logged.contains(login)) { logged.add(login); System.out.println("success: user logged in"); } else System.out.println("fail: already logged in"); } } if(mas[0].equals("logout")) { if (!map.containsKey(login)) System.out.println("fail: no such user"); if (!logged.contains(login)) System.out.println("fail: already logged out"); else { System.out.println("success: user logged out"); logged.remove(login); } } } } } It works, but cant pass the test |
|
|