提出 #8361991


ソースコード 拡げる

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 all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll n; cin >> n;
  ll k; cin >> k;

  vector<pair<P, ll>> res(n);
  set<ll> st;
  rep(i, 2 * n)st.insert(i);
  rep(i, n){
    ll mini = *(st.begin());
    ll jb = 2 * n - k + i - mini;
    auto itr = st.upper_bound(jb);
    if(itr != st.begin()){
      itr--;
      ll v1 = *itr;
      st.erase(itr);
      ll rem = 2 * n - k + i - v1;
      itr = st.upper_bound(rem);
      itr--;
      ll v2 = *itr;
      st.erase(itr);
      if(k + v2 + k + v1 > k + 2 * n + i){
        cout << -1 << endl;
        return 0;
      }
      res[i] = mk(mk(k + v2, k + v1), k + 2 * n + i);
    }else{
      cout << -1 << endl;
      return 0;
    }
  }

  rep(i, n){
    assert(res[i].first.first > 0);
    assert(res[i].first.second > 0);
    assert(res[i].second > 0);
    assert(res[i].first.first + res[i].first.second <= res[i].second);
  }

  rep(i, n){
    cout << res[i].first.first << " " << res[i].first.second << " " << res[i].second << endl;
  }
  return 0;
}

提出情報

提出日時
問題 E - Non-triangular Triplets
ユーザ fumiphys
言語 C++14 (GCC 5.4.1)
得点 0
コード長 3960 Byte
結果 RE
実行時間 243 ms
メモリ 13184 KB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 700
結果
AC × 2
AC × 27
WA × 5
RE × 6
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
in01.txt AC 225 ms 12416 KB
in02.txt AC 239 ms 12928 KB
in03.txt AC 233 ms 12800 KB
in04.txt AC 243 ms 13056 KB
in05.txt AC 221 ms 12160 KB
in06.txt AC 214 ms 11904 KB
in07.txt AC 229 ms 12544 KB
in08.txt AC 218 ms 12288 KB
in09.txt AC 219 ms 12032 KB
in10.txt AC 235 ms 13184 KB
in11.txt RE 160 ms 10112 KB
in12.txt WA 61 ms 10240 KB
in13.txt RE 165 ms 11136 KB
in14.txt WA 60 ms 9856 KB
in15.txt RE 158 ms 10112 KB
in16.txt RE 161 ms 10752 KB
in17.txt RE 165 ms 10880 KB
in18.txt WA 51 ms 9088 KB
in19.txt WA 59 ms 9856 KB
in20.txt RE 165 ms 11008 KB
in21.txt AC 69 ms 10880 KB
in22.txt AC 52 ms 9216 KB
in23.txt AC 232 ms 12928 KB
in24.txt AC 60 ms 10624 KB
in25.txt AC 125 ms 7296 KB
in26.txt AC 112 ms 6656 KB
in27.txt AC 56 ms 3456 KB
in28.txt AC 87 ms 5248 KB
in29.txt AC 49 ms 11264 KB
in30.txt AC 72 ms 11136 KB
in31.txt WA 72 ms 11136 KB
in32.txt AC 71 ms 11264 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