116 - Unidirectional TSP

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 116 - Unidirectional TSP WA-even so it passed all test c

Post by brianfry713 » Tue Oct 01, 2013 10:33 pm

Input:

Code: Select all

3 22
140 -247 -169 -156 -281 -460 254 -164 441 433 393 -374 -437 -471 -391 -222 237 225 392 381 242 47
95 333 -312 -101 -50 -364 -217 -428 -272 -224 177 412 120 396 -196 -125 -268 -255 160 -22 224 224
7 333 -498 97 410 -254 -22 -496 -355 -426 -311 185 325 140 321 -40 -436 -98 236 241 -186 209
AC output:

Code: Select all

3 1 3 1 1 1 2 3 3 3 3 1 1 1 1 1 3 2 2 2 3 1
-6027
Check input and AC output for thousands of problems on uDebug!

moody
New poster
Posts: 9
Joined: Tue Sep 24, 2013 2:19 am

Re: 116 - Unidirectional TSP WA-even so it passed all test c

Post by moody » Sat Oct 19, 2013 9:57 pm

brianfry713 wrote:Input:

Code: Select all

3 22
140 -247 -169 -156 -281 -460 254 -164 441 433 393 -374 -437 -471 -391 -222 237 225 392 381 242 47
95 333 -312 -101 -50 -364 -217 -428 -272 -224 177 412 120 396 -196 -125 -268 -255 160 -22 224 224
7 333 -498 97 410 -254 -22 -496 -355 -426 -311 185 325 140 321 -40 -436 -98 236 241 -186 209
AC output:

Code: Select all

3 1 3 1 1 1 2 3 3 3 3 1 1 1 1 1 3 2 2 2 3 1
-6027
thanks a lot i got accepted

yishiliu666
New poster
Posts: 4
Joined: Tue Mar 11, 2014 2:25 pm

Weired Runtime Error with exercise 116

Post by yishiliu666 » Tue Mar 11, 2014 2:35 pm

Can Anyone help check my code with problem 116? I am able to get correct result on my own machine but failed to be recognized by the UVa. It issued Runtime Error every time I posted it.
---------------------------------------------------------------------------

Code: Select all

import java.io.FileNotFoundException;
import java.util.Scanner;
class Unidirectional_TSP {
	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		new Unidirectional_TSP().calc();
		return ;
	}
	
	public void calc() throws FileNotFoundException{
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()){
			int tmprow = scan.nextInt();
			int tmpcol = scan.nextInt();
			int[][] mat_spec = new int[tmprow][tmpcol];
			for(int i=0; i<tmprow;i++)
				for(int j=0; j<tmpcol; j++){
					mat_spec[i][j] = scan.nextInt();
				}
			unitCalc(tmprow,tmpcol,mat_spec);
		}
	}
	
	private void unitCalc(int row, int col, int[][] spec){
			int result[][];
			int trace[][];
			
			result = new int[row][col];
			trace = new int[row][col]; 
			
			for(int i=0;i<row;i++){
				for(int j=0; j<col; j++){
					result[i][j] = (int) Double.MAX_VALUE;
				}
			}
			
			for(int i=0;i<row;i++){
				result[i][0] = spec[i][0];
			}
			
			for(int j=1; j<col; j++){
				for(int i=0;i<row;i++){
					for(int k=i-1;k<=i+1;k++){
						int wrap_k = (k+row)%row;
						if(result[wrap_k][j-1]+spec[i][j] <result[i][j] || (result[wrap_k][j-1]+spec[i][j] == result[i][j] && wrap_k <trace[i][j] )){
							result[i][j] = result[wrap_k][j-1]+spec[i][j]; 
							trace[i][j] = wrap_k;
						}
					}
				}
			}
			int winrow = pickLastCol(result, row, col);
			traceResult(trace, winrow, col-1);
			System.out.println("\n"+result[winrow][col-1]);
	}
	
	
	private int pickLastCol(int[][] result, int rowsize, int colsize) {
		// TODO Auto-generated method stub
		int winrow=0;
		int tmpsmallest=result[winrow][colsize-1];
		
		for(int i=0;i<rowsize;i++){
			if(result[i][colsize-1] < tmpsmallest){
				tmpsmallest = result[winrow][colsize-1];
				winrow = i;
			}
		}
		return winrow;
	}

	public void traceResult(int[][] trace, int i, int j){
			if(j==0){
				System.out.print(i+1+" ");
				return;
			}
			traceResult(trace, trace[i][j], j-1);
			System.out.print(i+1+" ");
	}
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Weired Runtime Error with exercise 116

Post by brianfry713 » Tue Mar 11, 2014 8:01 pm

Use class Main
Check input and AC output for thousands of problems on uDebug!

yishiliu666
New poster
Posts: 4
Joined: Tue Mar 11, 2014 2:25 pm

Re: Weired Runtime Error with exercise 116

Post by yishiliu666 » Wed Mar 12, 2014 7:03 am

brianfry713 wrote:Use class Main
Thanks for the pointer, it can run on UVa now. However I got Wrong Answer... couldn't really understand it since my approach seems to be right. Anyway, Could you kindly help me check my code. I've tested it using some cases as following.
5 6
3 4 1 2 8 6
6 1 8 2 7 4
5 9 3 9 9 5
8 4 1 3 2 6
3 7 2 8 6 4
5 6
3 4 1 2 8 6
6 1 8 2 7 4
5 9 3 9 9 5
8 4 1 3 2 6
3 7 2 1 2 3
2 2
9 10 9 10
6 2
-447 -242
-23 -409
60 -169
362 -136
413 -443
-165 20
8 1
40
-357
-459
-71
-43
48
-18
-104

and my code gave me
1 2 3 4 4 5
16
1 2 1 5 4 5
11
1 1
19
1 2
-856
3
-459
Which is absolutely right AFIK

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Weired Runtime Error with exercise 116

Post by brianfry713 » Wed Mar 12, 2014 11:30 pm

Don't print a space at the end of a line.
Check input and AC output for thousands of problems on uDebug!

sady
New poster
Posts: 17
Joined: Sat Dec 07, 2013 8:00 am

Re: 116 WA plz help

Post by sady » Tue Apr 22, 2014 8:13 am

:oops: I have tried all test case in the forum bt still WA. plz plz plz anyone help

Code: Select all

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
long long  tsp[10][100];
int  path[10][100], row, col;
int main()
{
    long long mini;
    int in[3]={-1,0,1},r,mr,c;
    while(scanf("%d %d", &row, &col)!=EOF)
    {
        for(int i=0;i<row;++i)
        {
            path[i][col-1] = -1;
            for(int j=0;j<col;++j)
            {
                scanf("%lld", &tsp[i][j]);
            }
        }
        for(int j=col-2;j>=0;--j) // last dik thk start krbo
        {
            for(int i=0;i<row;++i)
            {
                mini= tsp[i][j]+ tsp[i][j+1];
                mr=i;
                for(int k=0;k<3;++k)
                {
                    r=(i+ in[k] +row)%row;
                    if(mini > tsp[i][j]+ tsp[r][j+1] )
                    {
                        mini=tsp[i][j]+ tsp[r][j+1];
                        mr=r;
                        path[i][j]=mr;
                    }
                    else if(mini == (tsp[i][j]+ tsp[r][j+1]) )
                    {
                        mr=std::min(mr,r);
                        path[i][j]=mr;
                    }
                }
                tsp[i][j]=mini;


            }
        }
        mini = tsp[0][0];
        std::string s,t;
        r=0;c=0;
        s.clear();
        s+= r+1+48;
        while(path[r][c]!=-1)
        {
            r=path[r][c];
            s+= r+1+48;
            ++c;
        }
        for(int i=1;i<row;++i)
        {
            if( mini> tsp[i][0])
            {
               mini= tsp[i][0];
               r=i;c=0;
               s.clear();
               s+= r+1+48;
               //p.push(r);
               while(path[r][c]!=-1)
               {
                   r=path[r][c];
                   s+= r+1+48;
                   ++c;
               }

            }
            /*else if(mini== tsp[i][0])
            {
                r = i;c = 0;
                t.clear();
                t+= r+1+48;
               while(path[r][c] != -1)
               {
                   r=path[r][c];
                   t+= r+1+48;
                   ++c;
               }
               if(s.compare(t) > 0) s = t;
            }
            */
        }
        int len=s.size();
        printf("%c", s[0]);
        for(int i=1;i<len;++i)
        {
            printf(" %c", s[i]);
        }
        puts("");
        printf("%lld\n", mini);

    }
    return 0;
}

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 116 WA plz help

Post by lbv » Tue Apr 22, 2014 7:09 pm

sady wrote::oops: I have tried all test case in the forum bt still WA. plz plz plz anyone help
Try:

Input

Code: Select all

10 2
9 9
9 9
9 9
9 9
9 9
9 9
9 9
9 9
9 9
1 1
Output

Code: Select all

10 10
2

hami
New poster
Posts: 4
Joined: Thu Apr 25, 2013 9:12 pm

Re: 116 Help me

Post by hami » Sun Jun 22, 2014 6:33 pm

Hello,
I tried every test case there, but my code still cannot pass

Code: Select all

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;


public class Main {

	private static Scanner sc = new Scanner(System.in);
	private static long maticeVstupu [][];
	private static long maticeVypoctu [][];
	private static Pole maticeCesty [][];
	
	private static BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(System.out));
	public static void main(String[] args) throws IOException {		
		while(sc.hasNext()){			
			zpracovaniVstupu(sc.nextInt(),sc.nextInt());
		}
		bfw.close();
	}
			
	private static void zpracovaniVstupu(int pocetRadek, int pocetSlopcu) throws IOException {
		maticeVstupu = new long [pocetSlopcu][pocetRadek];
		maticeVypoctu = new long [pocetSlopcu][pocetRadek];
		maticeCesty = new Pole [pocetSlopcu][pocetRadek];
		
		for(int j = 0 ; j < pocetRadek ; j++){		
			for(int i = 0 ; i < pocetSlopcu ; i++){
				maticeVstupu [i][j] = sc.nextLong();
			}
		}
		for(int i = 0 ; i < pocetRadek ; i++){
			maticeVypoctu[0][i] = maticeVstupu[0][i];
			maticeCesty[0][i] = new Pole(0);
		}
		
//		System.out.println(Arrays.toString(maticeCesty[0][i].pole));
		long vysledek;
		int [] cesta = null;
		if(pocetRadek>1){
		for(int j = 1 ; j < pocetSlopcu ; j++){	
			int radka;
			for(int i = 0 ; i < pocetRadek ; i++){
				maticeCesty[j][i] = new Pole(j);
				
				if(i == 0){
					maticeVypoctu[j][i] = maticeVypoctu[j-1][i]+maticeVstupu[j][i];
					radka = i;
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][i+1] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][i+1] + maticeVstupu[j][i];
						radka = i+1;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][i+1] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][i+1],maticeCesty[j-1][radka]) ) {
						radka = i+1;
					}
					
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][pocetRadek-1] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][pocetRadek-1] + maticeVstupu[j][i];
						radka = pocetRadek-1;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][pocetRadek-1] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][pocetRadek-1],maticeCesty[j-1][radka]) ) {
						radka = pocetRadek-1;
					}
					
				}else if (i == pocetRadek-1) {
					maticeVypoctu[j][i] = maticeVypoctu[j-1][0]+maticeVstupu[j][i];
					radka = 0;
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][i-1] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][i-1] + maticeVstupu[j][i];
						radka = i-1;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][i-1] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][i-1],maticeCesty[j-1][radka]) ) {
						radka = i-1;
					}
					
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][i] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][i] + maticeVstupu[j][i];
						radka = i;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][i] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][i],maticeCesty[j-1][radka]) ) {
						radka = i;
					}
					
				}else{
					maticeVypoctu[j][i] = maticeVypoctu[j-1][i-1]+maticeVstupu[j][i];
					radka = i-1;
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][i] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][i] + maticeVstupu[j][i];
						radka = i;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][i-1] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][i-1],maticeCesty[j-1][radka]) ) {
						radka = i;
					}
					
					if(maticeVypoctu[j][i] > maticeVypoctu[j-1][i+1] + maticeVstupu[j][i]){
						maticeVypoctu[j][i] = maticeVypoctu[j-1][i+1] + maticeVstupu[j][i];
						radka = i+1;
					}else if ( (maticeVypoctu[j][i] == maticeVypoctu[j-1][i+1] + maticeVstupu[j][i]) && nizsiCesta(maticeCesty[j-1][i+1],maticeCesty[j-1][radka]) ) {
						radka = i+1;
					}
				}
//				System.out.println(Arrays.toString(maticeCesty[j-1][radka].pole));
				maticeCesty[j][i].pole = pridaniCesty((radka+1) , maticeCesty[j-1][radka].pole , j);
				
//				maticeCesty[j][i] = maticeCesty[j-1][radka]  + (radka+1)+ " ";
			}
		}
		vysledek = Long.MAX_VALUE;
		int radka = 0;
		for(int i = 0 ; i < pocetRadek ; i++){
			if(vysledek > maticeVypoctu[pocetSlopcu-1][i]){
				vysledek = maticeVypoctu[pocetSlopcu-1][i];
				cesta = maticeCesty[pocetSlopcu-1][i].pole;
				radka=i;
			}else if ( (vysledek == maticeVypoctu[pocetSlopcu-1][i]) && nizsiCesta(maticeCesty[pocetSlopcu-1][i],maticeCesty[pocetSlopcu-1][radka]) ) {
				radka = i;
				cesta = maticeCesty[pocetSlopcu-1][i].pole;
			}
		}
//		cesta += ""+(radka+1);
		cesta = pridaniCesty((radka+1) , cesta , cesta.length+1);
		}else{
			vysledek = 0;
			cesta = new int[pocetSlopcu];
			for(int i = 0 ; i < pocetSlopcu ; i++){				
					vysledek = vysledek + maticeVstupu[i][0];
					cesta[i]=1;
			}
		}		
		bfw.write(tiskCesty(cesta)+"\n");
//		bfw.write(Arrays.toString(cesta)+"\n");
		bfw.write(vysledek+"\n");
	}

	private static String tiskCesty(int [] pole){
		String string= String.valueOf(pole[0]);
		for(int i = 1 ; i < pole.length ; i++){
			string = string + " "+String.valueOf(pole[i]);
		}
		return string;
	}


	private static int[] pridaniCesty(int radka, int[] pole, int delka) {
//		System.out.println(Arrays.toString(pole));
		int pracPole [] = new int[delka];
		for(int i = 0; i < pole.length ; i++){
			pracPole[i] = pole[i];
		}
		pracPole[delka-1] = radka;
//		System.out.println(tiskCesty(pracPole));
		return pracPole;
	}

	/**
	 * pokud prvni mensi nez druhy - return true
	 * @param string
	 * @param string2
	 * @return
	 */
	private static boolean nizsiCesta(Pole a, Pole b) {
		int pole1 [] = a.pole;
		int pole2 [] = b.pole;
		if(pole1.length==0){
			return false;
		}
				
		for(int i = 0 ; i < pole1.length ; i++){
			if(pole1[i]<pole2[i]){
				return true;
			}
			if(pole1[i]>pole2[i]){
				return false;
			}
		}
		return false;
	}
}

class Pole{
	
	public int [] pole;
	
	Pole(int velikost){
		pole = new int[velikost];
	}
}

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 116 Help me

Post by lbv » Mon Jun 23, 2014 12:25 am

hami wrote:Hello,
I tried every test case there, but my code still cannot pass
You may try:

Input

Code: Select all

6 8
-7  -58  -78 -85  73  96  26 -68
68   33  -82 -80  79 -79 -35 -38
-35  91   24 -41 -60  74  20 -76
34    3  -49  23 -94 -27  46 -51
15   68  -35 -63  14  41 -31 -19
-77 -62  -49  52 -41  17  64  24
5 11
   8    2    2   11   10  -16   10   -4  -16  -15  -18
   3   -3    0    9  -13  -20   14   -2  -18    4    3
   2  -20   -6  -11  -17  -17    0   19  -18  -11    3
   4  -20   -8    8   10   10   15   16   12   -3   -8
  -7  -15    1   -7  -20   19   -3    4    3   20    6
7 12
 20  -1  14 -15 -14  20  10   3  18  10  12 -16
-20   1  18 -18 -15  13   2  11  -8   4 -14  -3
 18 -12  13 -10 -16 -14  -9 -16   7 -14 -11  14
-14 -20  -4 -15  10 -13 -10  10  10 -11  12  18
-19  -5   8  -7  20  16  13  17 -15   5 -12 -10
 13  -1  -6   1   7   3  -6  13   5  13 -20  -6
-19 -10 -15  14  -1  19  11   1  -6  -2  14  -7
Output

Code: Select all

6 1 2 2 3 2 2 3
-547
5 4 4 3 3 2 3 2 2 1 1
-136
5 4 4 4 3 3 4 3 2 3 2 1
-166

hami
New poster
Posts: 4
Joined: Thu Apr 25, 2013 9:12 pm

Re: 116 Help me

Post by hami » Mon Jun 23, 2014 7:56 pm

thx
accepted

I wrote wrong one if

ssshubhaa
New poster
Posts: 1
Joined: Tue Jul 29, 2014 11:12 pm

Re: 116 Help me

Post by ssshubhaa » Tue Jul 29, 2014 11:15 pm

I think thinking about when m=1 may help many people get ac :)

goldfenrir
New poster
Posts: 1
Joined: Mon Sep 15, 2014 7:07 am

Re: 116 - Unidirectional TSP

Post by goldfenrir » Mon Sep 15, 2014 7:15 am

Hi, Need some help. I tried a lot of tests, but the judge online stills send me a WA.
Ill really appreciate whatever help. I m using dp for solve it

Code: Select all

#include <cstdlib>
#include <cstdio>
#define MAX_C 100
#define MAX_R 10 
int min(int a,int b, int c){
    int mi=1<<20;
    if (a<mi) mi=a;
    if (b<mi) mi=b;
    if (c<mi) mi=c;
    return mi;
}
int main() {
    int matrix[MAX_R][MAX_C];
    int C[MAX_R][MAX_C];
    int d[MAX_C];
    int i1,i2,i3;
    int rows,columns,aux;
    while (scanf("%d%d",&rows,&columns)!=-1){
        if (rows<0 || columns<0) break;
            for (int i=0;i<rows;i++){
                for (int j=0;j<columns;j++){            
                    scanf("%d",&aux);
                    matrix[i][j]=aux;
                }
            }

            int i;
            for (i=0;i<rows;i++){
                C[i][0]=matrix[i][0];
            }

            for (int j=1;j<columns;j++){
                for (i=0;i<rows;i++){
                    i1=(i-1+((i-1)<0)*(rows))%(rows);
                    i2=(i+((i)<0)*(rows))%(rows);
                    i3=(i+1+((i+1)<0)*(rows))%(rows);
                    C[i][j]=min(C[i1][j-1],C[i2][j-1],C[i3][j-1])+matrix[i][j];
                }


            }
            int mi=1<<20,ind;
            for (i=0;i<rows;i++){
                    if (C[i][columns-1]<mi){
                        mi=C[i][columns-1];
                        ind=i;
                    }

            }
            d[columns-1]=ind+1; int inda;
            for (int j=1;j<columns;j++){
                mi=1<<20;
                inda=ind;
                ind=1<<20;
                for (int o=-1;o<=1;o++){

                    aux=(inda+o+((inda+o)<0)*(rows))%(rows);
                    if (C[aux][columns-1-j]<=mi){
                        if ((C[aux][columns-1-j]<mi)||(ind > aux && C[aux][columns-1-j]==mi)) ind=aux;
                        mi=C[aux][columns-1-j];

                    }

                }


                d[columns-1-j]=ind+1;

            }


            int j; 
            for (j=0;j<columns;j++){
                printf("%d",d[j]);
                if (j!=columns-1) printf(" ");
            }

            if (columns!=0 && rows!=0) printf("\n%d\n",C[d[columns-1]-1][j-1]);
    }
    return 0;
}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 116 - Unidirectional TSP

Post by brianfry713 » Mon Sep 15, 2014 8:24 pm

Input:

Code: Select all

6 8 
9 1 9 9 1 1 1 1 
1 9 9 1 9 9 9 9 
9 9 1 9 9 1 1 1 
1 1 9 9 1 9 9 9 
9 9 9 1 9 9 9 9 
9 9 1 9 9 9 9 9 
6 7
1 9 9 1 9 9 9
9 1 1 9 9 9 9
9 9 9 9 1 1 1
9 9 9 1 9 9 9
9 9 1 9 9 9 9
9 1 9 9 1 1 1
5 4
9 1 9 9
1 9 9 9
9 9 9 9
1 1 1 1
9 9 1 9
5 6
-3 -4 -1 -2 -8 -6
-6 -1 -8 -2 -7 -4 -5 -9 -3 -9 -9 -5
-8 -4 -1 -3 -2 -6 -3 -7 -2 -8 -6 -4
10 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
AC output:

Code: Select all

2 1 6 5 4 3 3 3
8
1 2 2 1 6 6 6
7
2 1 5 4
4
4 3 2 3 3 4
-49
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
100
Check input and AC output for thousands of problems on uDebug!

Ashur
New poster
Posts: 1
Joined: Mon Feb 15, 2016 9:43 pm

Help me please T.T

Post by Ashur » Mon Feb 15, 2016 9:50 pm

Hello!

I'be been testing my code with all the test cases mentioned in this forum, and in absolutely all of them I get the same answers as uDebug. But the judge gives me wrong answer T.T

I've been hours testing random inputs and all of them are the same as uDebug.

Could somebody help me?

Or.. can somebody find some input for which, my code doesn't work??

Here my code:
http://pastebin.com/sMEU8ry7

Thanks in advance!!

Post Reply

Return to “Volume 1 (100-199)”