QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140863#5160. Kebab PizzaMuhammadSawalhy#WA 1ms3584kbC++141.1kb2023-08-16 21:44:322023-08-16 21:44:33

Judging History

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

  • [2023-08-16 21:44:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3584kb
  • [2023-08-16 21:44:32]
  • 提交

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<pair<int, int>> toppings(n);
  vector<set<int>> adj(k);

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

  vector<set<int>> newadj = adj;

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

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

  cout << "possible\n";

  return 0;
}


// 2 2
// 3 6
// 6 6
// 6 5
// 4 5
// 1 5
// 1 1

// 2 3
// 3 4
// 4 5
// 3 6
// 6 7


详细

Test #1:

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

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: 3580kb

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: 3488kb

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: 3412kb

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: 3480kb

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: 3572kb

input:

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

output:

possible

result:

ok single line: 'possible'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3524kb

input:

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

output:

possible

result:

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