| Task: | Vaihdot |
| Sender: | suola_makkara |
| Submission time: | 2018-01-18 16:40:47 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 12 |
| #2 | ACCEPTED | 55 |
| #3 | ACCEPTED | 33 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | 1 | details |
| #2 | ACCEPTED | 0.05 s | 1 | details |
| #3 | ACCEPTED | 0.04 s | 1 | details |
| #4 | ACCEPTED | 0.04 s | 1 | details |
| #5 | ACCEPTED | 0.06 s | 1 | details |
| #6 | ACCEPTED | 0.04 s | 2 | details |
| #7 | ACCEPTED | 0.04 s | 2 | details |
| #8 | ACCEPTED | 0.05 s | 2 | details |
| #9 | ACCEPTED | 0.04 s | 2 | details |
| #10 | ACCEPTED | 0.04 s | 2 | details |
| #11 | ACCEPTED | 0.26 s | 3 | details |
| #12 | ACCEPTED | 0.29 s | 3 | details |
| #13 | ACCEPTED | 0.28 s | 3 | details |
| #14 | ACCEPTED | 0.26 s | 3 | details |
| #15 | ACCEPTED | 0.26 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:22:13: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(int i; i < n; i++)
^
input/code.cpp:30:13: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(int i; i < n; i++)
^Code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct OP
{
int a, b, c;
};
int main()
{
int a[500][500];
int b[500][500];
int n, ops = 0;
vector<OP> oper;
cin >> n;
for(int i; i < n; i++)
{
for(int j = 0; j < n; j++)
{
cin >> a[i][j];
}
}
for(int i; i < n; i++)
{
for(int j = 0; j < n; j++)
{
cin >> b[i][j];
}
}
for(int i = 0; i < n; i++)
{
bool br = 0;
int cor = b[i][i];
for(int x = i; x < n; x++)
{
for(int y = i; y < n; y++)
{
if(a[y][x] == cor)
{
br = 1;
if(i != y)
{
ops++;
//row 1 i y
oper.push_back({1, i + 1, y + 1});
swap(a[i], a[y]);
}
if(i != x)
{
ops++;
//col 2 i x
oper.push_back({2, i + 1, x + 1});
for(int x0 = 0; x0 < n; x0++)
{
swap(a[x0][i], a[x0][x]);
}
}
break;
}
}
if(br) break;
}
if(!br)
{
cout << -1;
return 0;
}
}
for(int x = 0; x < n; x++)
{
for(int y = 0; y < n; y++)
{
if(a[x][y] != b[x][y])
{
cout << -1;
return 0;
}
}
}
cout << ops << '\n';
for(OP o : oper)
{
cout << o.a << " " << o.b << " " << o.c << '\n';
}
}Test details
Test 1
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 3 2 1 7 4 3 6 8 9 5 1 7 2 ... |
| correct output |
|---|
| 2 2 1 3 2 1 2 |
| user output |
|---|
| 2 2 1 2 2 2 3 |
Test 2
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 3 3 7 2 1 5 6 4 8 9 7 3 2 ... |
| correct output |
|---|
| 2 1 2 3 2 1 2 |
| user output |
|---|
| 2 2 1 2 1 2 3 |
Test 3
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 3 3 7 8 4 5 1 6 9 2 3 8 7 ... |
| correct output |
|---|
| 1 2 2 3 |
| user output |
|---|
| 1 2 2 3 |
Test 4
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 3 3 1 8 5 2 6 9 4 7 3 1 8 ... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 5
Group: 1
Verdict: ACCEPTED
| input |
|---|
| 3 6 5 8 1 2 4 3 7 9 7 9 3 ... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 6
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 50 2080 2133 335 2071 1666 1889 4... |
| correct output |
|---|
| 89 1 1 27 1 1 47 1 1 32 1 1 2 ... |
| user output |
|---|
| 89 1 1 7 2 1 21 1 2 32 2 2 12 ... |
Test 7
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 50 59 2140 2044 1095 520 1562 153... |
| correct output |
|---|
| 88 1 1 29 1 1 47 1 1 3 1 1 26 ... |
| user output |
|---|
| 88 1 1 16 2 1 16 1 2 46 2 2 16 ... |
Test 8
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 50 1015 2205 747 1628 2184 61 189... |
| correct output |
|---|
| 94 1 1 17 1 1 30 1 1 15 1 1 3 ... |
| user output |
|---|
| 94 1 1 5 2 1 15 1 2 45 2 2 35 ... |
Test 9
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 50 1936 637 1930 1825 1375 688 23... |
| correct output |
|---|
| 88 1 1 45 1 1 34 1 1 26 1 1 21 ... |
| user output |
|---|
| 88 1 1 8 2 1 46 1 2 31 2 2 6 ... |
Test 10
Group: 2
Verdict: ACCEPTED
| input |
|---|
| 50 367 944 222 1047 2163 113 1076... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 11
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 125877 110081 73003 167540 184... |
| correct output |
|---|
| 986 1 1 222 1 1 325 1 1 203 1 1 73 ... |
| user output |
|---|
| 986 1 1 227 2 1 119 1 2 329 2 2 188 ... |
Test 12
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 98396 218927 201855 126130 103... |
| correct output |
|---|
| 983 1 1 80 1 1 125 1 1 242 1 1 85 ... |
| user output |
|---|
| 983 1 1 430 2 1 156 1 2 167 2 2 372 ... |
Test 13
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 54508 62242 106667 218403 5323... |
| correct output |
|---|
| 985 1 1 356 1 1 88 1 1 142 1 1 321 ... |
| user output |
|---|
| 985 1 1 358 2 1 46 1 2 500 2 2 317 ... |
Test 14
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 108478 62895 206775 78592 2247... |
| correct output |
|---|
| 986 1 1 182 1 1 253 1 1 365 1 1 413 ... |
| user output |
|---|
| 986 1 1 485 2 1 370 1 2 314 2 2 29 ... |
Test 15
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 500 96354 155542 19613 222634 1530... |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
