Different result in my compiler

Правка en3, от alexandar.100, 2017-06-04 07:28:10

This is very simple problem: 266B — Queue at the School. But somehow the codefoces compiler tells that i got wrong answer (BGGBG), although in my compiler it is right(GBGGB).

import java.util.Scanner;

public class Codeforces {

public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int n = scn.nextInt();
    int t = scn.nextInt();
    String str = scn.next();
    char[] chr = str.toCharArray();
    boolean chng = true;
    for(int ti = 1; ti <= t && chng; ti++){
        chng = false;
        for(int ni = 0; ni < n - 1; ni++){
            if(chr[ni + 1] == 'g' && chr[ni] == 'b'){
                chr[ni + 1] = 'b';
                chr[ni] = 'g';
                ni++;
                chng = true;
            }
        }
    }
    for(int i = 0; i < n; i++){
        System.out.print(chr[i]);
    }
}

}

Теги wrong answer on test 1, wrong answer, compiler

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский alexandar.100 2017-06-04 07:28:10 27 Tiny change: ' ' -> ' chng = false;\n '
en2 Английский alexandar.100 2017-06-04 07:26:36 5
en1 Английский alexandar.100 2017-06-04 07:25:32 972 Initial revision (published)