QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201656 | #5160. Kebab Pizza | Delay_for_five_minutes# | WA | 1ms | 8104kb | C++20 | 1.0kb | 2023-10-05 15:53:28 | 2023-10-05 15:53:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int k , n;
set<pair<int,int> > st;
vector<int> E[100005];
int deg[200005];
int in[200005];
int d2[200005];
bool ok[200005];
int main()
{
// freopen("in.txt","r",stdin) ;
ios::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
cin >> k >> n;
for(int i = 1;i <= k;i++) {
int a , b;cin >> a >> b;
if(a > b) swap(a, b) ;
if(st.count({a , b})) continue ;
st.insert({a , b}) ;
if(a == b) {
in[a] = 1;
}
else {
deg[a]++ ; deg[b]++ ;
E[a].push_back(b) ; E[b].push_back(a) ;
}
}
for(int i = 1;i <= n;i++) {
if(deg[i] == 1 && !in[i]) ok[i] = 0;
else ok[i] = 1;
}
int mx = 0;
for(int i = 1;i <= n;i++) {
for(auto v : E[i]) {
if(ok[v]) d2[i]++ ;
}
if(ok[i]) mx = max(mx , d2[i]) ;
}
if(mx <= 2) cout << "possible" ;
else cout << "impossible" ;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7024kb
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: 0ms
memory: 8104kb
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: 0ms
memory: 7260kb
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: 7484kb
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: 8012kb
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: 6896kb
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: 1ms
memory: 7488kb
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: 0ms
memory: 8100kb
input:
4 5 1 2 3 4 4 5 5 3
output:
possible
result:
wrong answer 1st lines differ - expected: 'impossible', found: 'possible'