CSES - HIIT Open 2016 - Results
Submission details
Task:Judge correctness
Sender:Barely Div 1
Submission time:2016-05-28 15:29:59 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#2ACCEPTED1.20 sdetails
#3ACCEPTED2.45 sdetails
#4--details
#5--details
#6--details
#7--details
#8ACCEPTED3.00 sdetails
#9--details
#10--details

Code

#include <vector>
#include <iostream>
#include <string>
using namespace std;
int getnum(char c) {
if (c >= 'A' && c <= 'Z') return c - 'A';
if (c >= 'a' && c <= 'z') return c - 'a' + 26;
if (c >= '0' && c <= '9') return c - '0' + 52;
if (c == '+') return 62;
return 63;
}
bool test(vector<vector<char>> & m, vector<vector<char>> & m_t, vector<vector<char>> & ans, vector<int> & r) {
int n = m.size();
vector<long long> check1(n);
vector<long long> check2(n);
for (int row = 0; row < n; row++) {
for (int col = 0; col < n; col++) {
check1[row] += r[col]*m_t[row][col];
}
check1[row] %= 64;
}
vector<long long> tmpr = check1;
for (int row = 0; row < n; row++) {
check1[row] = 0;
for (int col = 0; col < n; col++) {
check1[row] += tmpr[col]*m[row][col];
}
check1[row] %= 64;
}
for (int row = 0; row < n; row++) {
for (int col = 0; col < n; col++) {
check2[row] += r[col]*ans[row][col];
}
check2[row] %= 64;
}
return check1 == check2;
}
int main() {
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector<vector<char>> m(n);
vector<vector<char>> ans(n);
int ntmp = n;
int idx = 0;
while (ntmp--) {
string s; cin >> s;
for (auto c : s) {
m[idx].push_back(getnum(c));
}
idx++;
}
ntmp = n;
idx = 0;
while (ntmp--) {
string s; cin >> s;
for (auto c : s) {
ans[idx].push_back(getnum(c));
}
idx++;
}
vector<vector<char>> m_t(n, vector<char>(n));
for (int row = 0; row < n; row++) {
for (int col = 0; col < n; col++) {
m_t[col][row] = m[row][col];
}
}
bool printed = false;
for (int testn = 0; testn < 1; testn++) {
vector<int> r(n);
for (int i = 0; i < n; i++) {
r[i] = rand() % 64;
}
if (!test(m, m_t, ans, r)) {
cout << "0" << "\n";
printed = true;
break;
}
}
if (!printed) cout << "1" << "\n";
}
}

Test details

Test 1

Verdict:

input
500
12
N49lyQuAZh1l
PwNJA+wuTBr+
HO09lJg8kbup
...

correct output
0
0
1
1
1
...

user output
0
0
1
1
1
...

Test 2

Verdict: ACCEPTED

input
3
666
OvHf9jpB0RViia/ZD3gRQ7o1FELYh3...

correct output
0
0
1

user output
0
0
1

Test 3

Verdict: ACCEPTED

input
2
517
RWVknnH+hL6AfeKFbOu6OuAJL9dvLw...

correct output
0
1

user output
0
1

Test 4

Verdict:

input
1
5000
QP9pS1MOq6eDDKGQh//TrJUIvbM53a...

correct output
0

user output
(empty)

Test 5

Verdict:

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

correct output
1

user output
(empty)

Test 6

Verdict:

input
1
5000
b0V0j4vQ8CeiJrcUk2yssPF1B9EEDb...

correct output
1

user output
(empty)

Test 7

Verdict:

input
1
5000
VLdpW71f4Cdr+xdCRlwmAnNfMjqwMU...

correct output
0

user output
(empty)

Test 8

Verdict: ACCEPTED

input
1
5000
kBZaGETPWmyNR4NCvCPbJnvq2+JBfP...

correct output
0

user output
0

Test 9

Verdict:

input
1
5000
PES9AhJn+FZBVO5gqRLYbavSvaDUfU...

correct output
0

user output
(empty)

Test 10

Verdict:

input
1
5000
EoXwgdrAtKtV4M7jn0jAkNwkJX+be9...

correct output
1

user output
(empty)