You are not logged in. Please login at www.codechef.com to post your questions!

×

# Wrong Answer in Permutation Shuffle

 0 Can someone explain why this code in JAVA gives WA? import java.io.; import java.util.; class Permshuff { public static void main(String [] args) { InputReader1 reader = new InputReader1(System.in); PrintWriter out=new PrintWriter(System.out); int t=reader.nextInt(); while(t-->0) { int n=reader.nextInt(); int m=reader.nextInt(); boolean flag=true; Integer a[]=new Integer[n]; for(int i=0;i0) { int from=reader.nextInt(); int to=reader.nextInt(); Arrays.sort(a,from-1,to); } for(int i=0;i= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c & 15; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c & 15; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public String nextLine() { int c = read(); //while (c != '\n' && c != '\r' && c != '\t' && c != -1) //c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (c != '\n' && c != '\r' && c != '\t' && c != -1); return res.toString(); } public static boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }  } asked 03 Nov '14, 23:46 883●1●4●22 accept rate: 9% 0★admin ♦♦ 19.8k●350●498●541

One Answer:
 0 Can you read this and try to ask again? answered 04 Nov '14, 03:06 16.9k●49●115●225 accept rate: 11%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,313
×1,070
×856
×801
×183

question asked: 03 Nov '14, 23:46

question was seen: 1,059 times

last updated: 08 Jan '15, 15:54