QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#445357 | #5345. VivoParc | ogxazez | WA | 0ms | 3812kb | C++20 | 1.4kb | 2024-06-16 01:32:59 | 2024-06-16 01:32:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 105;
vector<int>e[maxn];
int n, c[maxn];
int sign;
int cnt[maxn][4];
void dfs(int x, int y)
{
if (y > 4) {
cout << x << " " << y << "\n";
}
// assert(y <= 4);
c[x] = y;
if (x == n)
{
sign = 1;
return;
}
for (int i = 0; i < e[x].size(); i++)
{
int v = e[x][i];
cnt[v][y]++;
}
for (int i = 1; i <= 4; i++)
{
if (cnt[x + 1][i]) continue;
dfs(x + 1, i);
if (sign) return;
}
for (int i = 0; i < e[x].size(); i++)
{
int v = e[x][i];
cnt[v][y]--;
}
}
int main()
{
// freopen("in.cpp", "r", stdin);
//freopen("out.cpp", "w", stdout);
cin >> n;
int x, y;
while (1) {
string s;
if (!(cin >> s)) break;
x = y = 0;
int j = 0;
for (; s[j] != '-'; ++j) {
x *= 10;
x += s[j] - '0';
}
++j;
for (; j < s.size(); ++j) {
y *= 10;
y += s[j] - '0';
}
e[x].push_back(y);
e[y].push_back(x);
}
for (int i = 1; i <= 4; i++)
{
dfs(1, i);
if (sign)break;
}
for (int i = 1; i <= n; i++) cout << i << " " << c[i] << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
8 1-2 3-1 4-5 4-8 1-7 1-4 7-1 2-4 1-8 6-7 2-3 1-5 1-6 7-6 7-8 2-5 7-1 3-4 5-6 7-8
output:
1 1 2 2 3 3 4 4 5 3 6 2 7 3 8 2
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
25 1-3 1-6 1-7 1-8 1-10 1-11 1-12 1-15 1-17 1-19 1-23 1-25 2-3 2-6 2-7 2-8 2-10 2-11 2-15 2-17 2-19 2-20 2-25 3-4 3-5 3-6 3-8 3-9 3-11 3-15 3-18 3-19 3-20 3-21 3-22 3-23 3-24 4-6 4-7 4-8 4-10 4-11 4-12 4-15 4-19 4-20 4-24 4-25 5-6 5-7 5-8 5-10 5-11 5-12 5-15 5-17 5-19 5-20 5-23 5-24 5-25 6-7 6-8 6-9...
output:
1 1 2 1 3 2 4 1 5 1 6 3 7 2 8 4 9 1 10 2 11 3 12 2 13 1 14 1 15 3 16 1 17 2 18 1 19 4 20 4 21 1 22 1 23 4 24 3 25 2
result:
ok good solution
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
50 1-2 1-9 1-10 1-12 1-21 1-22 1-37 37-1 1-40 1-42 1-46 2-3 2-9 2-10 2-11 2-14 2-22 2-26 2-30 2-33 33-2 2-34 2-36 2-38 2-39 2-40 2-43 2-47 3-7 3-8 3-11 11-3 3-12 3-16 3-20 3-21 3-26 3-27 3-28 3-29 3-32 3-33 3-35 3-39 39-3 3-40 3-46 3-47 3-49 4-7 4-8 4-9 4-10 4-11 4-19 4-20 20-4 4-21 4-26 4-27 4-30 3...
output:
18 14 19 10 20 6 24 12 25 8 27 6 29 27 30 23 31 19 32 15 33 11 34 7 36 12 37 8 39 49 40 45 41 41 42 37 43 33 44 29 45 25 46 21 47 17 48 13 49 9 50 5 1 1 2 2 3 1 4 1 5 1 6 2 7 3 8 2 9 3 10 3 11 3 12 4 13 1 14 1 15 4 16 4 17 4 18 14 19 10 20 6 21 2 22 3 23 3 24 12 25 8 26 4 27 6 28 2 29 27 30 23 31 19...
result:
wrong answer Integer parameter [name=id] equals to 18, violates the range [1, 1]