Code Submission Evaluation System Login

CSES - HIIT Open 2016

HIIT Open 2016

Contest start:2016-05-28 11:00:00
Contest end:2016-05-28 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard | Statistics


History
2016-05-28 15:48:44
2016-05-28 15:48:32
Task:Judge correctness
Sender:Oispa Kaljaa
Submission time:2016-05-28 15:48:44
Status:READY
Result:TIME LIMIT EXCEEDED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:13:9: warning: array subscript has type 'char' [-Wchar-subscripts]
     cn[c] = nyt;
         ^
input/code.cpp:18:9: warning: array subscript has type 'char' [-Wchar-subscripts]
     cn[c] = nyt;
         ^
input/code.cpp:23:9: warning: array subscript has type 'char' [-Wchar-subscripts]
     cn[c] = nyt;
         ^
input/code.cpp:46:19: warning: array subscript has type 'char' [-Wchar-subscripts]
    sum+=cn[a[i][k]]*cn[a[j][k]];
                   ^
input/code.cpp:46:31: warning: array subscript has type 'char' [-Wchar-subscripts]
    sum+=cn[a[i][k]]*cn[a[j][k]];
                               ^

Code

#include <bits/stdc++.h>

using namespace std;

string a[5050], x[5050];
int main(){
  cin.sync_with_stdio(0);
  cin.tie(0);
  int cn[1010];
  char nc[1010];
  int nyt = 0;
  for(char c = 'A'; c <= 'Z'; c++){
    cn[c] = nyt;
    nc[nyt] = c;
    nyt++;
  }
  for(char c = 'a'; c <= 'z'; c++){
    cn[c] = nyt;
    nc[nyt] = c;
    nyt++;
  }
  for(char c = '0'; c <= '9'; c++){
    cn[c] = nyt;
    nc[nyt] = c;
    nyt++;
  }
  cn['+'] = nyt;
  nc[nyt] = '+';
  nyt++;
  cn['/'] = nyt;
  nc[nyt] = '/';
  nyt++;
  
  int tests; cin >> tests;
  while(tests--){
    int n; cin >> n;
    for(int i = 0; i < n; i++)
      cin >> a[i];
    for(int i = 0; i < n; i++)
      cin >> x[i];
    bool ans = 1;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	int sum = 0;
	for(int k = 0; k < n; k++){
	  sum+=cn[a[i][k]]*cn[a[j][k]];
	}
	sum%=nyt;
	if(x[i][j] != nc[sum]){
	  ans = 0;
	  goto ohi;
	}
      }  
    }
    
    ohi:
    cout << ans << endl;
  } 
  return 0;
}