Contest Duration: - (local time) (120 minutes) Back to Home

Submission #10786534

Source Code Expand

Copy
// includes
#include <bits/stdc++.h>
using namespace std;

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;

struct tri{
ll a, b, c;
tri(){}
tri(ll a, ll b, ll c): a(a), b(b), c(c){}
};

int main(int argc, char const* argv[])
{
ll n, k; cin >> n >> k;
if(2 * k > n + 1){
cout << -1 << endl;
return 0;
}
vector<tri> res; res.reserve(n);
vector<bool> used(n, false);
for(ll i = 0; ; i++){
if(k + i + n + k - 1 >= k + 2 * n)break;
ll sum = k + i + k + i + n + k - 1;
while(sum < k + 2 * n || used[sum-k-2*n])sum++;
used[sum] = true;
res.pb(k + i, k + i + n + k - 1, sum);
}
for(ll i = n - k + 1; ; i++){
if(i + k - 1 >= n + k - 1)break;
ll sum = k + i + k + i + k - 1;
while(sum < k + 2 * n || used[sum-k-2*n])sum++;
used[sum] = true;
res.pb(k + i, k + i + k - 1, sum);
}

rep(i, n){
cout << res[i].a << " " << res[i].b << " " << res[i].c << "\n";
}
cout << flush;
return 0;
}

#### Submission Info

Submission Time 2020-03-13 04:16:59+0900 E - Non-triangular Triplets fumiphys C++14 (GCC 5.4.1) 0 3883 Byte RE 991 ms 4608 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
 AC × 2
 AC × 14 WA × 20 RE × 4
Set Name Test Cases
Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt WA 505 ms 4352 KB
in02.txt WA 991 ms 4480 KB
in03.txt WA 107 ms 4480 KB
in04.txt WA 207 ms 4608 KB
in05.txt WA 249 ms 4224 KB
in06.txt WA 82 ms 4224 KB
in07.txt WA 123 ms 4480 KB
in08.txt WA 805 ms 4352 KB
in09.txt WA 282 ms 4224 KB
in10.txt WA 540 ms 4608 KB
in11.txt WA 22 ms 4224 KB
in12.txt AC 22 ms 4224 KB
in13.txt WA 25 ms 4608 KB
in14.txt WA 21 ms 4096 KB
in15.txt WA 22 ms 4224 KB
in16.txt WA 23 ms 4480 KB
in17.txt WA 24 ms 4480 KB
in18.txt WA 20 ms 3712 KB
in19.txt WA 21 ms 4096 KB
in20.txt WA 24 ms 4608 KB
in21.txt AC 1 ms 256 KB
in22.txt AC 1 ms 256 KB
in23.txt WA 189 ms 4480 KB
in24.txt AC 1 ms 256 KB
in25.txt RE 124 ms 256 KB
in26.txt RE 96 ms 256 KB
in27.txt RE 147 ms 768 KB
in28.txt RE 96 ms 256 KB
in29.txt AC 1 ms 256 KB
in30.txt AC 1 ms 256 KB
in31.txt AC 24 ms 4608 KB
in32.txt AC 1 ms 256 KB
in33.txt AC 1 ms 256 KB
in34.txt AC 1 ms 256 KB
sample01.txt AC 1 ms 256 KB
sample02.txt AC 1 ms 256 KB