alexandar.100's blog

By alexandar.100, history, 9 years ago, In English

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]);
    }
}

}

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
9 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You must be kidding... The input 1 has uppercase letters and you are checking for lowercase ones, and you could get correct answer on your machine?

I'm not aware of the locales where JRE doesn't distinguish the case of letters.