ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1779. The Great Team

WA 13
Posted by SharpBlade 2 Jun 2012 23:06
Can anyone say, what is wrong in my solution?

public class T1779 {
    public static void main(String[] args) throws IOException {
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        int n=Integer.parseInt(in.readLine());
        int sum=0;
        for(int i=0; i<n/2; i++){
            for(int j=n-i-1; j<n; j++){
                if(i!=j){
                    out.println((i+1)+" "+(j+1));
                    sum++;
                }
            }
        }
        System.out.println(sum);
        out.close();

    }
}
Re: WA 13
Posted by Anti 28 Nov 2023 18:09
Repalce the conditions i != j with i < j because you print some edges twice.
Sorry for my bad English