Problem p02574 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repc(i, a, b, c)                                                       \\
  for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r)                                                              \\
  (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod) : 0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
// ll power(ll x, ll y) {
//     ll res = 1;x %= mod;
//     while (y > 0) {
//         if (y & 1)res = (res*x) % mod;
//         y = y>>1;
//         x = (x*x) % mod;
//     }
//     return res%mod;
// }
const int faxsize = 1e6 + 5;
vector<int> fax[faxsize];
// bool cmp(pair<int, int> a, pair<int, int> b){
//     return (a.fi+a.si) > (b.fi+b.si);
// }
// void solve(){
//     int n, s = 0;
//     cin >> n;
//     vector<pair<int, int> > v(n) ;
//     rep(i, 0, n)cin >> v[i].fi >> v[i].si, s += v[i].fi;
//     sort(all(v), cmp);
//     rep(i, 0, n){
//         if(v[i].fi+v[i].si <= s){
//             cout << "INDEFINITELY\\n";
//             return;
//         }
//         else s -= v[i].fi;
//     }
//     int mi, ans = s;
//     rep(i,0,n){
//         if()
//     }
// }

void solve() {
  int arr[faxsize] = {0};
  int n;
  cin >> n;
  int g = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    g = __gcd(a, g);
    for (auto i : fax[a])
      arr[i]++;
  }
  if (g != 1)
    cout << "not coprime\\n";
  else {
    rep(i, 0, faxsize) if (arr[i] > 1) {
      cout << "setwise coprime\\n";
      return;
    }
    cout << "pairwise coprime\\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // fact((2e6+10));
  // //declare  and  global
  rep(i, 2, faxsize) if (fax[i].size() == 0) repc(j, i, faxsize, i) fax[j]
      .push_back(i);
  int t = 1;
  // cin >> t;
  rep(i, 0, t) { solve(); }
}

Error: 0

Fixed submission:

#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define repc(i, a, b, c)                                                       \\
  for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n + 1) ft.pb((ft[i - 1] * i) % mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r)                                                              \\
  (n >= r ? ((ft[n] * mod_in((ft[r] * ft[(n) - (r)]) % mod)) % mod) : 0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\\n'
#define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/
// ll power(ll x, ll y) {
//     ll res = 1;x %= mod;
//     while (y > 0) {
//         if (y & 1)res = (res*x) % mod;
//         y = y>>1;
//         x = (x*x) % mod;
//     }
//     return res%mod;
// }
const int faxsize = 1e6 + 5;
vector<int> fax[faxsize];
// bool cmp(pair<int, int> a, pair<int, int> b){
//     return (a.fi+a.si) > (b.fi+b.si);
// }
// void solve(){
//     int n, s = 0;
//     cin >> n;
//     vector<pair<int, int> > v(n) ;
//     rep(i, 0, n)cin >> v[i].fi >> v[i].si, s += v[i].fi;
//     sort(all(v), cmp);
//     rep(i, 0, n){
//         if(v[i].fi+v[i].si <= s){
//             cout << "INDEFINITELY\\n";
//             return;
//         }
//         else s -= v[i].fi;
//     }
//     int mi, ans = s;
//     rep(i,0,n){
//         if()
//     }
// }

void solve() {
  int arr[faxsize] = {0};
  int n;
  cin >> n;
  int g = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    g = __gcd(a, g);
    for (auto i : fax[a])
      arr[i]++;
  }
  if (g != 1)
    cout << "not coprime\\n";
  else {
    rep(i, 0, faxsize) if (arr[i] > 1) {
      cout << "setwise coprime\\n";
      return;
    }
    cout << "pairwise coprime\\n";
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // fact((2e6+10));
  // //declare  and  global
  rep(i, 2, faxsize + 1) if (fax[i].size() == 0) repc(j, i, faxsize + 1, i)
      fax[j]
          .push_back(i);
  int t = 1;
  // cin >> t;
  rep(i, 0, t) { solve(); }
}