USACO Bronze January 2019 Problem 1

Hi! I need help with this USACO problem : http://www.usaco.org/index.php?page=viewproblem2&cpid=891
My solution:

#include <fstream>
#include <bits/stdc++.h>
#include <iostream>
 
using namespace std;
 
int main()
{
    ifstream fin ("shell.in");
    ofstream fout ("shell.out");
    int N , i;
    int A[N];
    int B[N];
    int G[N];
    fin >> N;
    for(i = 0 ; i  < N ; i++)
    {
      fin >> A[i] >> B[i] >> G[i];
    }
    int maximum_score = 0;
    for(i = 0 ; i < N ; i++)
    {
      if(A[i] == G[i])
      {
        maximum_score++;
      }
      else if(B[i] == G[i])
      {
        maximum_score++;
      }
    }
    fout << maximum_score;
}

thanks in advance :slight_smile:

Hi @Saicharan08,

Please read this module before asking for help on a problem.

In particular:

  • Include what you’ve attempted so far.
  • If you have code, post it (formatted as described here).

Thanks! :slight_smile:

Thanks! I have included my C++ code :slight_smile:
My solution could only pass 1 test case.
I don’t know what’s wrong. I think I did not understand the question.
Can you please explain me the swapping and guessing part? I also think I did not understand the input format well.

You should check the official solution or the one provided in USACO Guide.

1 Like