Could not resolve: (Domain name not found) TJU Problem 2501 Solution | Gal Appelbaum

TJU Problem 2501 Solution

Score, a relatively simple problem in the sense that it’s mainly tracing through a string… I solved this one in Java just because it seemed a little more challenging, even though once you use .toCharArray() the difference between java and C++ goes out the window… I tried keeping it simple, after all it was a problem in a programming competition and I didn’t want to spend too much time on it… so here’s the way I solved it.

It’s not necessarily the pretties code you’ll ever see, but it works.


*  TJU Problem 2501: Score

import java.util.Scanner;

//gotta rename it to submit...
public class p2501 {

    public static void main (String args[]){
        Scanner scn = new Scanner(;
        final int cases = Integer.parseInt(scn.nextLine());
        for(int i = 0; i <= cases; i++){
            int finalAnswer = 0;
            int counter = 0;
            final char[] string = scn.nextLine().toCharArray();
            if(string[0] == 'O'){
                finalAnswer= finalAnswer + counter;
            for(int j = 1; j< string.length; j++){
                if(string[j] == 'O' && string[j-1] == string[j])
                else if(string[j] == 'O')
                    counter = 1;
                    counter = 0;
                finalAnswer= finalAnswer + counter;

Leave a Reply

Your email address will not be published. Required fields are marked *