Here is the code in C++. 

Can you please clarify - When testing on local machine is it sufficient to 
enter inputs from keyboard. Or should the program run from redirected 
standard input and output. My program works when I enter input manually 
from keyboard. I am using cin for reading No of cases and N. For reading 
the matrix I use getline. If I do not make any changes and run by 
redirecting input and output

myprogram.exe < input > output

I do not get proper results.

---------------------------------------

#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include <ios>
#include <limits>
using namespace std;
int main() {
  int C;
  cin >> C;
  for (int caseno = 1; caseno <= C; caseno++) {
    int N; cin >> N;
    int tracesum=0;   
    string numbers;
    int intnumbers;
    
    vector<bool> rowsrepeat;
    vector<bool> colsrepeat;
    vector<bool> arrelementrowcount1;
    vector <vector<bool> > arrelementrowcount2;
    vector<bool> arrelementcolcount1;
    vector <vector<bool> > arrelementcolcount2;
    int rowsrepeatnum=0;
    int colsrepeatnum=0;
    for (int i=0; i<N; i++) {
      rowsrepeat.push_back(false);
      colsrepeat.push_back(false);
    }
    for (int i=0; i<=N; i++) { 
      arrelementrowcount1.push_back(false);
    }
    for (int i=0; i<N; i++) {  
      arrelementrowcount2.push_back(arrelementrowcount1);
    }
    for (int i=0; i<=N; i++) { 
      arrelementcolcount1.push_back(false);
    }
    for (int i=0; i<N; i++) {  
      arrelementcolcount2.push_back(arrelementcolcount1);
    }
    vector<int>  arrinput1;
    vector <vector<int> >  arrinput2;
    for (int i=0; i<N; i++) {        
        arrinput1.clear();
        cin.sync();
        getline(cin, numbers);
        istringstream ss(numbers);    
        while (ss >> intnumbers) {
          arrinput1.push_back(intnumbers);          
        }  
        arrinput2.push_back(arrinput1);
    }         
    int i=0;int j=0;    
    for (auto it1 = arrinput2.begin(); it1 != arrinput2.end(); it1++) {
      j=0;
      for (auto it2 = (*it1).begin(); it2 != (*it1).end(); it2++ ) {    
      int in = *it2;
        if (arrelementrowcount2[i][in]) {          
          rowsrepeat[i] = true;          
        }
        arrelementrowcount2[i][in] = true;
        if (arrelementcolcount2[j][in]) {          
          colsrepeat[j] = true;          
        }
        arrelementcolcount2[j][in] = true;
        if (i==j) {
          tracesum = tracesum + in;                
        }
        j++;      
        
      }
     i++; 
     
    }              
    
    for (int i=0; i<N; i++) {
      if (rowsrepeat[i]) rowsrepeatnum++; 
      if (colsrepeat[i]) colsrepeatnum++;       
    }
      
      cout << "Case #" << caseno << ":" << " " << tracesum << " " << 
rowsrepeatnum << " " << colsrepeatnum << endl;        
} 
}
-------------------------

Any help will be appreciated.

Thanks

Saimohan Kuncham

On Wednesday, April 8, 2020 at 9:22:25 PM UTC+5:30, Saimohan Kuncham wrote:
>
> When I run my code locally using MinGW compiler I am getting the right 
> answers. 
>
> I have tried the sample testcases given in the problem and they also give 
> the correct results when run locally. On the Code jam environment I am 
> getting wrong results both in test (where I manually enter the inputs)and 
> attempt when I run the program. 
>
> My program which compiles and runs without any errors should work at least 
> for the Sample testcases. What could be the problem ?
>
> Is there any specific name for the cpp file which I have to upload ? I 
> tried renaming to Solution.cc and then upload it but it did not help.
>
> Any help will be appreciated.
>
> Thanks
> Saimohan Kuncham
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/2f1dbc94-0255-486d-80b5-73bebcfaec37%40googlegroups.com.

Reply via email to