Submission #1121397

#TimeUsernameProblemLanguageResultExecution timeMemory
1121397qrnLutrija (COCI19_lutrija)C++14
Compilation error
0 ms0 KiB
]#include <bits/stdc++.h> using namespace std; #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back #define endl "\n" #define ALL(x) x.begin(), x.end() #define intt long long const intt mxN = 2e5 + 5, L = 20, mxA = 5e5 + 35; bool isprime(intt n) { for(int i = 2; i <= sqrt(n); i++) { if(n % i == 0) return false; } return true; } vector<vector<intt>>graph; vector<intt> parent(mxN, 0), visited(mxN, 0), path, memopath, v(mxN); bool ok = false; void dfs(intt u, intt end) { visited[u] = true; path.pb(u); if (u == end) { ok = true; cout << path.size() << endl; for(int i = 0; i < path.size(); i++) { if(i < path.size() - 1 && v[path[i]] == v[path[i+1]]) { continue; } if(v[path[i]] == v[end]) { cout << v[path[i]] << " "; return; } else { cout << v[path[i]] << " "; } } return; } else { for (intt v : graph[u]) { if (!visited[v]) { dfs(v, end); } } } path.pop_back(); visited[u] = false; } void solve() { intt l,r, li =0, ri = 0; cin >> l >> r; v.resize(8); v = {-mxA, 2, l - 2, r - 2, l, r, l + 2, r + 2}; sort(ALL(v)); graph.resize(8); for(intt i = 1; i <= 7; i++) { if(v[i] == l) li = i; if(v[i] == r) ri = i; for(intt j = i + 1; j <= 7; j++) { if(isprime(v[i]) && isprime(v[j]) && isprime(abs(v[i]-v[j])) && v[i] && v[j]){ graph[i].pb(j); graph[j].pb(i); } } } dfs(li, ri); if(!ok) { cout << -1 << endl; } } int main() { SPEED; int tst = 1; // cin >> tst; while (tst--) { solve(); } return 0; }

Compilation message (stderr)

lutrija.cpp:1:2: error: stray '#' in program
    1 | ]#include <bits/stdc++.h>
      |  ^
lutrija.cpp:1:1: error: expected unqualified-id before ']' token
    1 | ]#include <bits/stdc++.h>
      | ^
lutrija.cpp: In function 'bool isprime(long long int)':
lutrija.cpp:17:25: error: 'sqrt' was not declared in this scope
   17 |     for(int i = 2; i <= sqrt(n); i++) {
      |                         ^~~~
lutrija.cpp: At global scope:
lutrija.cpp:23:1: error: 'vector' does not name a type
   23 | vector<vector<intt>>graph;
      | ^~~~~~
lutrija.cpp:24:1: error: 'vector' does not name a type
   24 | vector<intt> parent(mxN, 0), visited(mxN, 0), path, memopath, v(mxN);
      | ^~~~~~
lutrija.cpp: In function 'void dfs(long long int, long long int)':
lutrija.cpp:28:5: error: 'visited' was not declared in this scope
   28 |     visited[u] = true;
      |     ^~~~~~~
lutrija.cpp:29:5: error: 'path' was not declared in this scope
   29 |     path.pb(u);
      |     ^~~~
lutrija.cpp:33:9: error: 'cout' was not declared in this scope
   33 |         cout << path.size() << endl;
      |         ^~~~
lutrija.cpp:35:39: error: 'v' was not declared in this scope
   35 |             if(i < path.size() - 1 && v[path[i]] == v[path[i+1]]) {
      |                                       ^
lutrija.cpp:38:16: error: 'v' was not declared in this scope
   38 |             if(v[path[i]] == v[end]) {
      |                ^
lutrija.cpp:47:23: error: 'graph' was not declared in this scope
   47 |         for (intt v : graph[u]) {
      |                       ^~~~~
lutrija.cpp: In function 'void solve()':
lutrija.cpp:61:5: error: 'cin' was not declared in this scope
   61 |     cin >> l >> r;
      |     ^~~
lutrija.cpp:62:5: error: 'v' was not declared in this scope
   62 |     v.resize(8);
      |     ^
lutrija.cpp:64:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   64 |     sort(ALL(v));
      |     ^~~~
      |     short
lutrija.cpp:66:5: error: 'graph' was not declared in this scope
   66 |     graph.resize(8);
      |     ^~~~~
lutrija.cpp:71:58: error: 'abs' was not declared in this scope
   71 |             if(isprime(v[i]) && isprime(v[j]) && isprime(abs(v[i]-v[j])) && v[i] && v[j]){
      |                                                          ^~~
lutrija.cpp:79:7: error: 'cout' was not declared in this scope
   79 |       cout << -1 << endl;
      |       ^~~~
lutrija.cpp: In function 'int main()':
lutrija.cpp:5:5: error: 'ios_base' has not been declared
    5 |     ios_base::sync_with_stdio(0); \
      |     ^~~~~~~~
lutrija.cpp:84:5: note: in expansion of macro 'SPEED'
   84 |     SPEED;
      |     ^~~~~
lutrija.cpp:6:5: error: 'cin' was not declared in this scope
    6 |     cin.tie(NULL);                \
      |     ^~~
lutrija.cpp:84:5: note: in expansion of macro 'SPEED'
   84 |     SPEED;
      |     ^~~~~
lutrija.cpp:6:13: error: 'NULL' was not declared in this scope
    6 |     cin.tie(NULL);                \
      |             ^~~~
lutrija.cpp:84:5: note: in expansion of macro 'SPEED'
   84 |     SPEED;
      |     ^~~~~
lutrija.cpp:1:1: note: 'NULL' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
  +++ |+#include <cstddef>
    1 | ]#include <bits/stdc++.h>
lutrija.cpp:7:5: error: 'cout' was not declared in this scope
    7 |     cout.tie(NULL);
      |     ^~~~
lutrija.cpp:84:5: note: in expansion of macro 'SPEED'
   84 |     SPEED;
      |     ^~~~~