QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140890#5160. Kebab PizzaMuhammadSawalhy#WA 1ms3576kbC++14918b2023-08-16 22:29:502023-08-16 22:29:51

Judging History

你现在查看的是最新测评结果

  • [2023-08-16 22:29:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3576kb
  • [2023-08-16 22:29:50]
  • 提交

answer

// ﷽
#include <bits/stdc++.h>

using namespace std;

#ifdef SAWALHY
#include "debug.hpp"
#else
#define debug(...) 0
#define debug_itr(...) 0
#define debug_bits(...) 0
#endif

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);

  int n, k;
  cin >> n >> k;

  vector<set<int>> adj(k);

  for (int i = 0, a, b; i < n; i++) {
    cin >> a >> b;
    a--, b--;
    adj[a].insert(b);
    adj[b].insert(a);
  }

  auto newadj = adj;

  for (int i = 0; i < k; i++) {
    if (adj[i].size() == 1) {
      newadj[*adj[i].begin()].erase(i);
    }
    if (newadj[i].size() > 2) {
      newadj[i].erase(i);
    }
  }

  for (int i = 0; i < k; i++) {
    if (newadj[i].size() > 2) {
      cout << "impossible\n";
      exit(0);
    }
  }

  cout << "possible\n";
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3500kb

input:

7 6
2 2
3 6
1 1
1 5
4 5
6 6
6 5

output:

possible

result:

ok single line: 'possible'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3460kb

input:

5 5
1 3
1 5
2 3
2 5
3 4

output:

possible

result:

ok single line: 'possible'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

6 7
1 2
2 3
3 4
4 5
3 6
6 7

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

8 4
1 1
1 2
2 1
2 2
3 3
3 4
4 3
4 4

output:

possible

result:

ok single line: 'possible'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

4 4
1 2
2 1
3 4
4 3

output:

possible

result:

ok single line: 'possible'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

5 4
1 1
1 4
2 2
2 4
3 4

output:

possible

result:

ok single line: 'possible'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

6 4
1 1
1 4
2 2
2 4
3 3
3 4

output:

impossible

result:

ok single line: 'impossible'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3520kb

input:

4 5
1 2
3 4
4 5
5 3

output:

possible

result:

wrong answer 1st lines differ - expected: 'impossible', found: 'possible'