QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133888 | #5160. Kebab Pizza | BUET_TEAM_ONE# | WA | 3ms | 5948kb | C++20 | 1.4kb | 2023-08-02 16:33:37 | 2023-08-02 16:33:39 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long int ll;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fill(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define debug(x) { cerr << #x << " = " << x << endl; }
#define IO { ios_base::sync_with_stdio(false); cin.tie(0); }
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define N 100009
using namespace std;
const double inf = 1e18;
const double pi = acos(-1);
vector<pll> a;
vector<ll> v[N];
bool sp[N]={false};
void solve() {
ll n, m; cin>> n>> m;
for(ll i=0; i<n; i++){
ll g, h; cin>> g>> h;
if(g>h) swap(g,h);
if(g==h){
sp[g]=true;
}
else{
a.pb(mp(g,h));
}
}
for(ll i=0; i<a.size(); i++){
if(i==0 || (i>0 && a[i]!=a[i-1])){
v[a[i].first].pb(a[i].second);
v[a[i].second].pb(a[i].first);
}
}
bool ans = true;
for(ll i=1; i<=m; i++){
ll g = 0;
for(ll j=0; j<v[i].size(); j++){
ll k = v[i][j];
if(v[k].size()>1 || sp[k]) g++;
}
if(g>2) ans = false;
}
(ans)? cout<< "possible\n" : cout<< "impossible\n";
}
int main() {
IO;
cout << fixed << setprecision(10);
solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5948kb
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: 5768kb
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: 3ms
memory: 5820kb
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: 5832kb
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: 5932kb
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: 5888kb
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: 5928kb
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: 5948kb
input:
4 5 1 2 3 4 4 5 5 3
output:
possible
result:
wrong answer 1st lines differ - expected: 'impossible', found: 'possible'