QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201678 | #5160. Kebab Pizza | Delay_for_five_minutes# | WA | 2ms | 10980kb | C++20 | 1.7kb | 2023-10-05 16:04:14 | 2023-10-05 16:04:15 |
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];
vector<int> G[100005];
bool vis[100005];
int tv , te;
void dfs(int u)
{
vis[u] = 1;
tv++ ;
for(auto v : G[u]) {
if(!vis[v]) {
dfs(v) ;
}
te++;
}
}
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++) {
if(!ok[i]) continue ;
for(auto v : E[i]) {
if(ok[v]) {d2[i]++ ;
G[i].push_back(v) ;}
}
if(ok[i]) mx = max(mx , d2[i]) ;
}
if(mx <= 2) {
int has_l = 0 , has_c = 0;
for(int i = 1;i <= n;i++) {
if(ok[i] && !vis[i]) {
tv = 0 , te = 0;
dfs(i) ; te /= 2;
if(tv == 1 && !in[i]) continue ;
if(tv == te) has_c++;
else has_l++;
}
}
if((has_c && has_l) || (has_c >= 2)) cout << "impossible";
else cout << "possible" ;
}
else cout << "impossible" ;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 10840kb
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: 2ms
memory: 10968kb
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: 2ms
memory: 10980kb
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: 0ms
memory: 10916kb
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: 0ms
memory: 10888kb
input:
4 4 1 2 2 1 3 4 4 3
output:
possible
result:
ok single line: 'possible'
Test #6:
score: 0
Accepted
time: 2ms
memory: 10828kb
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: 10908kb
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: 2ms
memory: 10920kb
input:
4 5 1 2 3 4 4 5 5 3
output:
possible
result:
wrong answer 1st lines differ - expected: 'impossible', found: 'possible'