Show all threads Hide all threads Show all messages Hide all messages |
HINT | Varun Sharma | 1313. Some Words about Sport | 7 Jun 2021 10:23 | 3 |
HINT Varun Sharma 6 May 2009 10:26 Hi, Well it took me a while to figure out as to how to approach this problem but as it turned out it is pretty straightforward. I divided the problem into two parts. First I printed out the elements up until the middle diagonal. And then the elements after that. Here is the format of the numbers for 4 X 4 array 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 2,0 2,1 2,2 2,3 3,0 3,1 3,2 3,3 We can see a pattern here. First print the element 0,0. Then -> 1,0 to 0,1 (i = 1 to i = 0 and j = 0 to j = 1) Then -> 2,0 to 0,2 (i = 2 to i = 0 and j = 0 to j = 2) Then -> 3,0 to 0,3 (i = 3 to i = 0 and j = 0 to j = 3) So, basically as we are heading towards the main diagonal, we are increasing the value of i and at the same time running j from 0 to i. Implementing this will get you the first 10 out of 16. For the rest of them, we have the same pattern again but this time its reverse Then -> 3,1 to 1,3 (i = 3 to i = 1 and j = 1 to j = 3) Then -> 3,2 to 2,3 (i = 3 to i = 2 and j = 2 to j = 3) Then the last element 3,3 So, this just requires some clever manipulation of the for loops or while loops. Re: HINT Lifeisbeautiful 23 Dec 2020 12:53 |
AC on C++ | Arman Sykot | 1313. Some Words about Sport | 28 Oct 2020 21:11 | 1 |
/* * Author : Arman Sykot * Date & time : 28.10.2020 21:47:12 +06 */ #include <bits/stdc++.h> #define ll long long #define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; int main() { the_flash; int n; cin >> n;
int arr[n][n];
for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> arr[i][j]; }
for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { cout << arr[i - j][j] << " "; } }
for (int i = n; i < 2 * n - 1; i++) { for (int j = n - 1; j >= i - (n - 1); j--) cout << arr[j][i - j] << " "; }
cout << "\n";
return 0; } |
Acces Violation test #4 and after that get WA #4, C++. Anyone can help me? still stuck test #4 | VNeo | 1313. Some Words about Sport | 15 Jul 2017 13:03 | 4 |
first i get acces violation in my code. and then i search what it acces violation, and then i remake my code, then submit again. still get WA #4, before i reamke the code it says Accces Violation in test #4. Can anybody help me? This is my code. #include <iostream> using namespace std; int n,ar[10000],p; int main(){ cin>>n; for (int i=1;i<=n*n;i++){ cin>>p; ar[p]=p; } for (int i=1;i<=n*n;i++){cout<<ar[i]<<' ';} } Edited by author 15.07.2017 10:58 Or I must use Array 2 dimensions? http://ideone.com/8vvdveIf you don't want runtime error #4 pay attention arrays in C/C++ are 0-indexing and enlarge your array by one for example If you want AC you can AC even with one-d array To do that you should write much more smart program than yours understood. thnks dude. Edited by author 15.07.2017 13:05 Edited by author 15.07.2017 13:05 |
WA #4 | Someone Else | 1313. Some Words about Sport | 21 Dec 2014 14:37 | 1 |
WA #4 Someone Else 21 Dec 2014 14:37 Solution in Go. I was getting WA#4 and then changed my input matrix from [][]int8 to [][]int16 and the solution was accepted. Edited by author 21.12.2014 14:38 |
Wrong Answer in test 4. What is wrong? Please help | Maksadbek | 1313. Some Words about Sport | 6 Oct 2014 22:11 | 1 |
import java.util.Scanner; public class Main { public static int[] insertation_sort(int[] toBeSorted){ for(int i=1; i<toBeSorted.length; i++){ int x = toBeSorted[i]; int y = i; while( y>0 && (toBeSorted[y-1] > x)){ toBeSorted[y] = toBeSorted[y -1]; y -= 1; } toBeSorted[y] = x; } return toBeSorted; } public static void some_words_about_sport() { Scanner scanner = new Scanner(System.in); int times = Integer.parseInt(scanner.nextLine()); int[] inputNumbers = new int[times*times]; int counter=0; for (int i = 0; i < times; i++) { for(int l =0; l<times; l++){ int inputs = scanner.nextInt(); inputNumbers[counter] = inputs; counter++; } } inputNumbers = insertation_sort(inputNumbers); //print the solution for(int x: inputNumbers){ System.out.print(String.format("%d ", x)); } } public static void main(String[] args) { some_words_about_sport(); System.exit(0); } } |
Wrong Answe test 4 java | shagi | 1313. Some Words about Sport | 2 Oct 2014 18:54 | 1 |
I don't understand what's wrong? In my IDEA all works! import java.io.IOException; import java.util.Scanner; public class summa { public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] mas = new int[n*n]; if(n!= 0) { for (int i = 0; i < n * n; i++) { mas[i]=s.nextInt(); } if(mas.length>1) { qSort(mas, 0, mas.length-1); for (int i = 0; i < mas.length; i++) { System.out.print(mas[i] + " "); } }else System.out.println(mas[0]); }else System.out.println("0 элемнтов"); } public static void qSort(int[] A, int low, int high) { int i = low; int j = high; int x = A[(low+high)/2]; do { while(A[i] < x) ++i; while(A[j] > x) --j; if(i <= j){ int temp = A[i]; A[i] = A[j]; A[j] = temp; i ++ ; j --; } } while(i <= j);
if(low < j) qSort(A, low, j); if(i < high) qSort(A, i, high); } } Edited by author 02.10.2014 20:36 Edited by author 02.10.2014 20:36 |
help me | Zoirov Eldor (TUIT Urgench) | 1313. Some Words about Sport | 8 Jul 2014 13:28 | 1 |
help me Zoirov Eldor (TUIT Urgench) 8 Jul 2014 13:28 #include <stdio.h> #include<conio.h> main() { int x[100][100],a,i,j; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j < a ; j++ ) scanf("%d",&x[i][j]); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j <= i ; j++ ) printf("%d ",x[i-j][j]); for( i = a ; i < 2 * a - 1 ; i++ ) for( j = a - 1 ; j >= i - 3 ; j-- ) printf("%d ",x[j][i-j]); getch(); } |
Can anybody help me please? What is wrong with my code? | Александр | 1313. Some Words about Sport | 6 Jan 2014 17:13 | 3 |
#include <stdio.h> #include<conio.h> main() { int x[100][100],a,i,j; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j < a ; j++ ) scanf("%d",&x[i][j]); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j <= i ; j++ ) printf("%d ",x[i-j][j]); for( i = a ; i < 2 * a - 1 ; i++ ) for( j = a - 1 ; j >= i - 3 ; j-- ) printf("%d ",x[j][i-j]); getch(); } Maybe, in order to get full credit point from this task, you should delete the "getch()" ? I do not want to see your sorting algorithm... #include <stdio.h> #include<conio.h> main() { int x[100][100],a,i,j; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j < a ; j++ ) scanf("%d",&x[i][j]); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j <= i ; j++ ) printf("%d ",x[i-j][j]); for( i = a ; i < 2 * a - 1 ; i++ ) for( j = a - 1 ; j >= i - (a-1) ; j-- ) printf("%d ",x[j][i-j]); } Here's the correct code |
byte - > integer | Sasori | 1313. Some Words about Sport | 30 Oct 2013 06:10 | 1 |
i don't understand / numbers which are in this problem 1 .. 100, and i used byte = wrong #4 / then i replace byte -> integer and obtained accepted / why |
AC Python 3.3 | lomobit | 1313. Some Words about Sport | 27 Jul 2013 23:54 | 1 |
num = int(input()) arr = [] for i in range(num): temp_arr = input().split(' ') arr.append(temp_arr) string = '' for i in range(num): k = i j = 0 while k >= 0: string += (arr[k][j] + ' ') k -= 1 j += 1 for i in range(1,num,1): k = num - 1 j = i while j != num: string += (arr[k][j] + ' ') k -= 1 j += 1 print(string) |
Wrong statement. | oxoxonin | 1313. Some Words about Sport | 1 Jun 2013 22:44 | 2 |
As I can see this statement is wrong: "Пиксели нумеруются от левого верхнего угла, по диагоналям, слева-направо и снизу-вверх". There should be "сверху-вниз". Am I right? No, you are not right. See one more time: 1 3 6 2 5 8 4 7 9 :) |
Why "Crash (access violation)" ? totally misunderstood | Dastan Yelubayev | 1313. Some Words about Sport | 16 Mar 2013 11:22 | 2 |
Hello all. I have some problem with this task? Why crash:acces violation? Here is the code ------------------------------------------------- #include <iostream> #include <map> #include <algorithm> #include <vector> using namespace std; int main () { int n,i,j; int a[100]; cin>>n; for( i=0;i<n*n;i++) cin>>a[i]; sort(a,a+n*n); for( i=0;i<n*n;i++) cout<<a[i]<<" "; return 0; } I didn't use two dimensional arrays cause I'had tried to find the laziest way. Could u help ? Local test on computer is pretty good, u can check by trying code by yourselves; The problem is not to sort array. Check it again!!! |
wa on #3 | Shuhan | 1313. Some Words about Sport | 15 Mar 2013 00:42 | 2 |
first i hav taken input of 2d array.........and then sorted them using merge sort..... i know there is a problem in my logic.......but i can't find it......help me find it please..... #include<stdio.h> int main() { int n,c,i,j,k,l,num; scanf("%d",&n); c=n-1; int ar[c][c]; num=1; for(i=c;i>=0;i--) { for(j=0;j<n-i;j++) { ar[i][j]=num; num++; } } for(j=1;j<=c;j++) { for(i=0;i<n-i;i++) { ar[i][j]=num; num++; } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { printf("%d ",ar[i][j]); } printf("\n"); } return 0; }
Hi, First of all, you don't need to sort the array. Read the Question properly, we just need to Reprint the Array in a Different Pattern of Diagnals, which is given in the Sample Output. |
To Admins! | kami_botanik | 1313. Some Words about Sport | 4 Mar 2013 22:50 | 3 |
Hi! Sorry, how i can have WA 1# if my program generate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 at first test? Re: To Admins! Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 4 Mar 2013 22:46 Do you have 16 in the end of the list? Look at the sample output - it is there Sorry, I have it, I just forgive write it at the sample for you. Program code has generate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 isn't right? |
Please Help! Program is right! But I don't know what's a problem? | kami_botanik | 1313. Some Words about Sport | 3 Mar 2013 05:32 | 1 |
I know you must'll say that this is like a "Axe slyle" But i sit on this task aproximately 7 hours! And I have already sick of it, but i owed to finish it! However Programm is working! I tested it and it's all right! PLEASE HEEEELP me! I have WA# 2. (((
using System; namespace ConsoleApplication1 { class Program14 { static void Main() { int p = 0; int u = 0; int q = 0; int k = 0; int i = 0; int j = 0; int n = int.Parse(Console.ReadLine()); string[] str; int[,] x = new int[n,n]; for (i = 0; i < n; i++) { str = Console.ReadLine().Split(' '); for (p = 0; p < n; p++) x[i, p] = int.Parse(str[p]); }
int[] y = new int[x.Length]; for (i = 1; i >= 0; i--) { k++; y[k] = x[i, k - 1];
for (j = 2; j >= 0; j--) { q++; if (q == 4) break; y[q + 2] = x[j, q - 1];
for (int o = 3; o >= 0; o--) { u++; if (u >= 5) break; y[u+5] = x[o, u - 1]; } }
} for (i = 3; i >= 2; i--) { y[k + 11] = x[i, k]; k++; } for (i = 3; i >= 1; i--) { q++; y[q+5] = x[i, q-4]; } y[0] = x[0, 0]; y[15] = x[3, 3]; foreach (int s in y) Console.Write("{0} ", s); Console.ReadLine();
} } }
Please prompt, Where is the problem! And sorry for my also "Dehqon style" english. |
100*100 not enough? | $wordfish | 1313. Some Words about Sport | 16 Sep 2012 16:44 | 3 |
So the problems says that 1 <= N <= 100, so I declare a nice unsigned char mem[100*100]. I get WA on test 4. I go and read all the discussion about wrong awsers but none of those offer anything I didn't figure out already. I change the declaration to unsigned char mem[256*256] and voila, the solution is magically accepted. Does anyone have an idea why 100*100 bytes aren't enough? I wrote a solution in Pascal (ages ago :-)), which AFAIR checks whether index is in range while accessing to some element in array. And I had [1..100,1..100]. That is why I suppose that somewhere in your program you access out of array. 100x100 is enough, assuming you start your indexing at 0 and end at n-1 |
hint | orcchg | 1313. Some Words about Sport | 14 Sep 2012 03:15 | 2 |
hint orcchg 22 Aug 2011 21:31 use array of N queues Edited by author 25.08.2011 19:25 |
WA on test #3 C Help me | Ahmet Terzi(Ottoman)Devlet-i Âli Osman | 1313. Some Words about Sport | 31 Aug 2012 19:45 | 1 |
what's wrong in my code? Here is my code: #include <stdio.h> main() { int x[100][100],a,i,j; scanf("%d",&a); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j < a ; j++ ) scanf("%d",&x[i][j]); for( i = 0 ; i < a ; i++ ) for( j = 0 ; j <= i ; j++ ) printf("%d ",x[i-j][j]); for( i = a ; i < 2 * a - 1 ; i++ ) for( j = a - 1 ; j >= i - 3 ; j-- ) printf("%d ",x[j][i-j]); return 0; } Edited by author 31.08.2012 20:24 |
WA #4-Java | d_shuren | 1313. Some Words about Sport | 7 Aug 2012 15:57 | 1 |
import java.util.Scanner; public class KVoprosuOSporte { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[][] a = new int[n][n]; int k = 0; int[] b = new int[n * n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = in.nextInt(); b[k] = a[i][j]; k++; } } for (int i = 0; i < b.length - 1; i++) { for (int j = i + 1; j < b.length; j++) { if (b[i] > b[j]) { int tmp = b[i]; b[i] = b[j]; b[j] = tmp; } } } for (int i = 0; i < b.length; i++) { System.out.println(b[i]); } } } |
why wa #1??? | Artem Fast | 1313. Some Words about Sport | 9 Jul 2012 01:44 | 2 |
my programm return "1 2 3 4 5 6 7 8 9 10 11 12 14 13 15 16" in the first test, but i have wa #1??? why??? You have "14 13" not "13 14". I'm pretty sure that's what's wrong. Good luck! |