Submission #781515

#TimeUsernameProblemLanguageResultExecution timeMemory
781515makanhuliaNaboj (COCI22_naboj)C++17
0 / 110
150 ms20848 KiB
#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,pre,a,b; set<ll> st; ll temp1,temp2; vector<ll> adj[200200],v; 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-1) { cout << -1 << endl; return 0; } pre = -1; for(auto i : v) { if(pre != -1 && i - pre > 2) { cout << -1 << endl; return 0; } pre = i; } pre = -1; FOR(0,i,v.size()-1) { if(pre != -1) { if(v[i] - pre != 1) { temp1 = i; break; } } cout << v[i] << " 1" << endl; pre = v[i]; } pre = -1; FORM(v.size()-1,i,1) { if(pre != -1) { if(v[i] - pre != 1) { temp2 = i; break; } } cout << v[i] << " 1" << endl; pre = i; } FOR(temp1,i,temp2) { 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 (stderr)

naboj.cpp: In function 'int main()':
naboj.cpp:36:16: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |   if(st.size() < n/2 || st.size() == n-1) {
      |      ~~~~~~~~~~^~~~~
naboj.cpp:36:35: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   36 |   if(st.size() < n/2 || st.size() == n-1) {
      |                         ~~~~~~~~~~^~~~~~
naboj.cpp:13:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 | #define FOR(m,i,n) for(int i=(m); i<=(n); i++)
      |                                    ^
naboj.cpp:49:3: note: in expansion of macro 'FOR'
   49 |   FOR(0,i,v.size()-1) {
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...