Code Submission Evaluation System Login

HIIT Open 2016

Start:2016-05-28 11:00:00
End:2016-05-28 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2016 - Results
History
2016-05-28 15:43:58
2016-05-28 15:40:41
2016-05-28 15:40:11
2016-05-28 15:38:34
2016-05-28 15:37:28
2016-05-28 15:31:54
2016-05-28 15:29:59
2016-05-28 15:28:54
2016-05-28 15:28:04
2016-05-28 15:25:47
2016-05-28 15:24:55
2016-05-28 15:18:42
2016-05-28 15:16:31
2016-05-28 14:35:59
2016-05-28 13:13:15
Task:Judge correctness
Sender:Barely Div 1
Submission time:2016-05-28 15:43:58
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.05 / 3.00details
#2ACCEPTED0.50 / 3.00details
#3ACCEPTED1.18 / 3.00details
#4ACCEPTED1.05 / 3.00details
#5ACCEPTED1.46 / 3.00details
#6ACCEPTED1.46 / 3.00details
#7ACCEPTED1.04 / 3.00details
#8ACCEPTED1.03 / 3.00details
#9ACCEPTED1.04 / 3.00details
#10ACCEPTED1.45 / 3.00details

Compiler report

input/code.cpp: In function 'void printmat(std::vector<std::vector<char> >)':
input/code.cpp:38:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < M.size(); i++){
                               ^
input/code.cpp:39:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j = 0; j < M.size(); j++){
                                 ^

Code

#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <utility>

using namespace std;

typedef char LL;
/*
vector<LL> matmul(vector<vector<LL> > M, vector<LL> v){
  int n = v.size();
  vector<LL> ans(n);
  for(int i = 0; i < n; i++){
    LL x = 0;
    for(int j = 0; j < n; j++){
      x += M[i][j] * v[j];
    }
    ans[i] = x % 64;
  }
  return ans;
}*/

void matmul2(vector<LL> & ans, vector<vector<LL> > M, vector<LL> v){
  int n = v.size();
  //vector<LL> ans(n);
  for(int i = 0; i < n; i++){
    int64_t x = 0;
    for(int j = 0; j < n; j++){
      x += M[i][j] * (int64_t) v[j];
    }
    ans[i] = x % 64;
  }
  //return ans;
}

void printmat(vector<vector<LL> > M){
    for(int i = 0; i < M.size(); i++){
      for(int j = 0; j < M.size(); j++){
	cout << M[i][j] << " ";
      }
      cout << endl;
    }
}

void read_matrix(vector< vector<LL> > & M, int64_t n){
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    for(int j = 0; j < n; j++){
      int64_t x = 0;
      if(s[j] >= 'A' && s[j] <= 'Z') x = s[j] - 'A';
      if(s[j] >= 'a' && s[j] <= 'z') x = s[j] - 'a' + 26;
      if(s[j] >= '0' && s[j] <= '9') x = s[j] - '0' + 52;
      if(s[j] == '+') x = 62;
      if(s[j] == '/') x = 63;
      M[i][j] = x;
    }
  }  //return M;
}

void solve(){
  int64_t n; cin >> n;
  vector<vector<LL> > A(n, vector<LL>(n));
  vector<vector<LL> > X(n, vector<LL>(n));
  read_matrix(A, n);
  read_matrix(X, n);
  vector<vector<LL> > A_T(n, vector<LL>(n)); // transpose
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      A_T[i][j] = A[j][i];
    }
  }  
  //printmat(A); printmat(A_T); printmat(X);
  
  for(int test = 0; test < 5; test++){
    vector<LL> v;
    for(int i = 0; i < n; i++){
      v.push_back(rand() % 64);
    }
    
    vector<LL> Xv(n), t(n), AA_Tv(n);
    
    matmul2(Xv, X,v);
    matmul2(t, A_T,v);
    matmul2(AA_Tv, A, t);
    
    //vector<LL> Xv(n); // DEBUG
    //vector<LL> AA_Tv(n); // DEBUG
    
    bool good = true;
    
    for(int i = 0; i < n; i++){
      if(Xv[i] != AA_Tv[i]) good = false;
    }
    
    if(!good){
      cout << 0 << "\n";
      return;
    }
  }
  
  cout << 1 << "\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin.tie(0);
  srand(345348345);
  int64_t t; cin >> t;
  while(t--) solve();
}

Test details

Test 1

Verdict: ACCEPTED

input
500
12
N49lyQuAZh1l
PwNJA+wuTBr+
HO09lJg8kbup
yDfjEETO9FbY
Aplqi5vnLc98
0/hYfkOFcZVV
/ckgzeISmwGl
br2MOJZnYtrh
fEUiVy4Miasn
0u09RS8s83nZ
gQjEE8dDfIk7
g8si6nOeea01
XCc/9qK8WGTj
CK39fpfbB/4q
c3GYFr/oDwzG
/9Yf5gOIARp8
9fF53gW9SfQF
qprggzi/g4br
...
view   save

correct output
0
0
1
1
1
0
0
0
0
0
1
1
0
0
0
1
0
0
1
1
...
view   save

user output
0
0
1
1
1
0
0
0
0
0
1
1
0
0
0
1
0
0
1
1
...
view   save

Test 2

Verdict: ACCEPTED

input
3
666
OvHf9jpB0RViia/ZD3gRQ7o1FELYh3...
L5gSvHpMnBJLnEP2owz8yZ7PgwI62l...
view   save

correct output
0
0
1
view   save

user output
0
0
1
view   save

Test 3

Verdict: ACCEPTED

input
2
517
RWVknnH+hL6AfeKFbOu6OuAJL9dvLw...
FM2IGsbyia33qivbugYG85wbElidVu...
view   save

correct output
0
1
view   save

user output
0
1
view   save

Test 4

Verdict: ACCEPTED

input
1
5000
QP9pS1MOq6eDDKGQh//TrJUIvbM53a...
view   save

correct output
0
view   save

user output
0
view   save

Test 5

Verdict: ACCEPTED

input
1
5000
RSX7ZuQE6A94s8s+9oP1uCDHRkmZ+7...
view   save

correct output
1
view   save

user output
1
view   save

Test 6

Verdict: ACCEPTED

input
1
5000
b0V0j4vQ8CeiJrcUk2yssPF1B9EEDb...
view   save

correct output
1
view   save

user output
1
view   save

Test 7

Verdict: ACCEPTED

input
1
5000
VLdpW71f4Cdr+xdCRlwmAnNfMjqwMU...
view   save

correct output
0
view   save

user output
0
view   save

Test 8

Verdict: ACCEPTED

input
1
5000
kBZaGETPWmyNR4NCvCPbJnvq2+JBfP...
view   save

correct output
0
view   save

user output
0
view   save

Test 9

Verdict: ACCEPTED

input
1
5000
PES9AhJn+FZBVO5gqRLYbavSvaDUfU...
view   save

correct output
0
view   save

user output
0
view   save

Test 10

Verdict: ACCEPTED

input
1
5000
EoXwgdrAtKtV4M7jn0jAkNwkJX+be9...
view   save

correct output
1
view   save

user output
1
view   save