Submission #781551

# Submission time Handle Problem Language Result Execution time Memory
781551 2023-07-13T07:55:37 Z andecaandeci Strange Device (APIO19_strange_device) C++17
0 / 100
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

strange_device.cpp: In function 'int main()':
strange_device.cpp:37: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]
   37 |   if(st.size() < n/2 || st.size() == n) {
      |      ~~~~~~~~~~^~~~~
strange_device.cpp:37: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]
   37 |   if(st.size() < n/2 || st.size() == n) {
      |                         ~~~~~~~~~~^~~~
strange_device.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++)
      |                                    ^
strange_device.cpp:41:3: note: in expansion of macro 'FOR'
   41 |   FOR(1,i,v.size()-1) {
      |   ^~~
strange_device.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++)
      |                                    ^
strange_device.cpp:49:3: note: in expansion of macro 'FOR'
   49 |   FOR(1,i,v.size()-1) {
      |   ^~~
# 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 -