# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781551 | 2023-07-13T07:55:37 Z | andecaandeci | Strange Device (APIO19_strange_device) | C++17 | 3 ms | 4960 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define endl "\n" #define pii pair<ll,ll> #define pb push_back #define vi vector<ll> #define pque priority_queue #define pqueg priority_queue<ll,vector<ll>,greater<ll>> #define que queue<ll> #define FOR(m,i,n) for(int i=(m); i<=(n); i++) #define FORM(m,i,n) for(int i=(m); i>=(n); i--) ll n,m,a,b; set<ll> st; ll temp1,temp2; vector<ll> adj[200200],v; bool vis[200200]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; FOR(1,i,m) { cin >> a >> b; adj[a].pb(b); adj[b].pb(a); st.insert(a); } for(auto i : st) { v.pb(i); } if(n == 2) { cout << a << " 1" << endl; return 0; } if(st.size() < n/2 || st.size() == n) { cout << -1 << endl; return 0; } FOR(1,i,v.size()-1) { if(v[i] - v[i-1] > 2) { cout << -1 << endl; return 0; } } cout << v[0] << " 1" << endl; vis[0] = true; FOR(1,i,v.size()-1) { if(v[i] - v[i-1] == 1) { temp1 = i; vis[i] = true; cout << v[i] << " 1" << endl; } else { break; } } if(!vis[v.size()-1]) { cout << v[v.size()-1] << " 1" << endl; } FORM(v.size()-2,i,temp1+1) { if(v[i+1] - v[i] == 1 && !vis[i]) { temp2 = i; cout << v[i] << " 1" << endl; } else { break; } } // cout << "temp1 " << temp1 << endl; // cout << "temp2 " << temp2 << endl; FOR(temp1,i,temp2) { if(vis[i]) continue; cout << v[i] << " 1" << endl; } } /* 9 8 1 2 2 3 3 4 5 4 5 6 6 7 7 8 8 9 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4924 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4924 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4924 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4960 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |