Submission #251320

# Submission time Handle Problem Language Result Execution time Memory
251320 2020-07-20T19:38:00 Z Bruteforceman Lutrija (COCI19_lutrija) C++11
14 / 70
2000 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long x) {
  if(x <= 1) return false;
  for(int i = 2; 1LL * i * i <= x; i++) {
    if(x % i == 0) {
      return false;
    }
  }
  return true;
}
void good(vector <long long> v) {
  for(auto i : v) if(!isPrime(i)) return ;
  for(int i = 1; i < v.size(); i++) if(!isPrime(abs(v[i] - v[i - 1]))) {
    return ;
  }
  cout << v.size() << endl;
  for(auto i : v) {
    cout << i << " ";
  }
  cout << endl;
  exit(0);
}
int main() {
  long long A, B;
  cin >> A >> B;
  vector <long long> v ({A, B});
  good(v);
  for(auto i : {2LL, A + 2, A - 2, B + 2, B - 2}) {
    auto u = v;
    u.insert(u.begin() + 1, i);
    good(u);
    for(auto j : {2LL, A + 2, A - 2, B + 2, B - 2}) {
      u.insert(u.begin() + 2, j);
      good(u);
    }
  }
  cout << -1 << endl;
  return 0;
}

Compilation message

lutrija.cpp: In function 'void good(std::vector<long long int>)':
lutrija.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 1; i < v.size(); i++) if(!isPrime(abs(v[i] - v[i - 1]))) {
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2054 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2098 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -