Task: | Judge correctness |
Sender: | asdf |
Submission time: | 2024-09-28 15:59:16 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
#3 | RUNTIME ERROR | 2.49 s | details |
#4 | RUNTIME ERROR | 0.20 s | details |
#5 | RUNTIME ERROR | 0.20 s | details |
#6 | RUNTIME ERROR | 0.20 s | details |
#7 | RUNTIME ERROR | 0.20 s | details |
#8 | RUNTIME ERROR | 0.20 s | details |
#9 | RUNTIME ERROR | 0.20 s | details |
#10 | RUNTIME ERROR | 0.20 s | details |
Compiler report
In file included from /usr/include/c++/11/cassert:44, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33, from input/code.cpp:1: input/code.cpp: In constructor 'Matrix::Matrix(const std::vector<std::vector<int> >&)': input/code.cpp:79:47: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare] 79 | /**/ for (auto x : d) assert(x.size() == size); | ~~~~~~~~~^~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:50:20: warning: statement has no effect [-Wunused-value] 50 | #define debug(...) 42 | ^~ input/code.cpp:196:5: note: in expansion of macro 'debug' 196 | debug(S); | ^~~~~
Code
#include <bits/stdc++.h> using namespace std; // #define int long long string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif using type = int; // Kiểu dữ liệu các phần tử của ma trận struct Matrix { vector <vector <type> > data; // Số lượng hàng của ma trận int row() const { return data.size(); } // Số lượng hàng của ma trận int col() const { return data[0].size(); } auto & operator [] (int i) { return data[i]; } const auto & operator[] (int i) const { return data[i]; } Matrix() = default; Matrix(int r, int c): data(r, vector <type> (c)) { } Matrix(const vector <vector <type> > &d): data(d) { // Kiểm tra các hàng có cùng size không và size có lớn hơn 0 hay không // Tuy nhiên không thực sự cần thiết, ta có thể bỏ các dòng /**/ đi /**/ assert(d.size()); /**/ int size = d[0].size(); /**/ assert(size); /**/ for (auto x : d) assert(x.size() == size); } // In ra ma trận. friend ostream & operator << (ostream &out, const Matrix &d) { for (auto x : d.data) { for (auto y : x) out << y << ' '; out << '\n'; } return out; } // Ma trận đơn vị static Matrix identity(long long n) { Matrix a = Matrix(n, n); while (n--) a[n][n] = 1; return a; } // Nhân ma trận Matrix operator * (const Matrix &b) { Matrix a = *this; // Kiểm tra điều kiện nhân ma trận assert(a.col() == b.row()); Matrix c(a.row(), b.col()); for (int i = 0; i < a.row(); ++i) for (int j = 0; j < b.col(); ++j) for (int k = 0; k < a.col(); ++k) { c[i][j] += a[i][k] * b[k][j]; } return c; } // Lũy thừa ma trận Matrix pow(long long exp) { // Kiểm tra điều kiện lũy thừa ma trận (là ma trận vuông) assert(row() == col()); Matrix base = *this, ans = identity(row()); for (; exp > 0; exp >>= 1, base = base * base) if (exp & 1) ans = ans * base; return ans; } }; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int Rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); } const int N = 5005; string S; int n; int decode(char c) { if (isupper(c)) return c - 'A'; if (islower(c)) return 26 + c - 'a'; if (isdigit(c)) return 52 + c - '0'; if (c == '+') return 62; return 63; } char encode(int x) { return S[x]; } void solve() { cin >> n; Matrix a(n, n), at(n, n), x(n, n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; a[i][j] = decode(c); at[j][i] = decode(c); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; x[i][j] = decode(c); } } int ite = 10; bool correct = true; while (ite--) { Matrix v(n, 1); for (int i = 0; i < n; i++) v[i][0] = Rand(0, 1); Matrix lhs = (a * at * v); Matrix rhs = x * v; for (int i = 0; i < n; i++) { if (lhs[i][0] % 64 != rhs[i][0] % 64) { correct = false; break; } } if (!correct) break; } cout << correct << '\n'; } signed main() { cin.tie(0)->sync_with_stdio(0); for (char c = 'A'; c <= 'Z'; c++) S += c; for (char c = 'a'; c <= 'z'; c++) S += c; for (char c = '0'; c <= '9'; c++) S += c; S += '+'; S += '/'; debug(S); int t; cin >> t; while (t--) { solve(); } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
500 12 N49lyQuAZh1l PwNJA+wuTBr+ HO09lJg8kbup ... |
correct output |
---|
0 0 1 1 1 ... |
user output |
---|
0 0 1 1 1 ... Truncated |
Test 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
3 666 OvHf9jpB0RViia/ZD3gRQ7o1FELYh3... |
correct output |
---|
0 0 1 |
user output |
---|
(empty) |
Test 3
Verdict: RUNTIME ERROR
input |
---|
2 517 RWVknnH+hL6AfeKFbOu6OuAJL9dvLw... |
correct output |
---|
0 1 |
user output |
---|
(empty) |
Test 4
Verdict: RUNTIME ERROR
input |
---|
1 5000 QP9pS1MOq6eDDKGQh//TrJUIvbM53a... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 5
Verdict: RUNTIME ERROR
input |
---|
1 5000 RSX7ZuQE6A94s8s+9oP1uCDHRkmZ+7... |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 6
Verdict: RUNTIME ERROR
input |
---|
1 5000 b0V0j4vQ8CeiJrcUk2yssPF1B9EEDb... |
correct output |
---|
1 |
user output |
---|
(empty) |
Test 7
Verdict: RUNTIME ERROR
input |
---|
1 5000 VLdpW71f4Cdr+xdCRlwmAnNfMjqwMU... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 8
Verdict: RUNTIME ERROR
input |
---|
1 5000 kBZaGETPWmyNR4NCvCPbJnvq2+JBfP... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 9
Verdict: RUNTIME ERROR
input |
---|
1 5000 PES9AhJn+FZBVO5gqRLYbavSvaDUfU... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 10
Verdict: RUNTIME ERROR
input |
---|
1 5000 EoXwgdrAtKtV4M7jn0jAkNwkJX+be9... |
correct output |
---|
1 |
user output |
---|
(empty) |