QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#118128 | #6643. Graphs and Colors | 5ab | WA | 2ms | 3320kb | C++14 | 1.1kb | 2023-07-03 09:00:49 | 2023-07-03 09:00:50 |
Judging History
answer
/* name: 6643
* author: 5ab
* created at: 2023-07-03
*/
#include <iostream>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))
using ll = long long;
const int max_n = 100;
int g[max_n][max_n];
void conn(int x, int y, int c) { g[x][y] = g[y][x] = c; }
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int cas, n, k;
cin >> cas;
while (cas--)
{
cin >> n >> k;
if (k > n / 2)
{
cout << "NO\n";
continue;
}
cout << "YES\n";
for (int i = 0; i < k; i++)
{
int x = i * 2, y = i * 2 + 1;
conn(x, y, i + 1);
for (int j = 0; j < k; j++)
if (j < i)
{
conn(x, j * 2 + 1, i + 1);
conn(y, j * 2, i + 1);
}
else if (j > i)
{
conn(x, j * 2, i + 1);
conn(y, j * 2 + 1, i + 1);
}
}
for (int i = k * 2; i < n; i++)
for (int j = 0; j < i; j++)
conn(i, j, 1);
for (int i = 1; i < n; i++)
for (int j = 0; j < i; j++)
cout << g[i][j] << " \n"[j == i - 1];
}
return 0;
}
// started coding at: 07-03 08:52:02
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3320kb
input:
768 8 24 7 20 17 61 17 76 16 100 16 16 15 59 9 17 14 31 14 61 10 32 17 55 5 7 10 29 14 82 13 47 17 32 5 10 16 76 14 59 8 28 13 19 12 41 13 41 11 32 11 53 3 2 16 52 16 87 7 12 9 15 15 65 15 53 17 47 6 15 12 1 14 35 16 60 12 31 14 70 15 88 12 2 8 23 12 38 16 111 16 117 5 4 14 90 12 55 15 41 15 48 15 4...
output:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 NO NO NO NO NO YES 1 1 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer Graph is not correct (test case 42)