Submission #14809976
Source Code Expand
Copy
// May this submission get accepted
#include <bits/stdc++.h>
// エイリアス
using ll = long signed long;
using ull = long unsigned long;
using ld = long double;
using namespace std;
// AtCoder/Codeforces 用 デバッグ検知
#ifdef ONLINE_JUDGE
constexpr bool DEBUG_MODE = false;
#else
constexpr bool DEBUG_MODE = true;
#endif
// エイリアス (補完・コンパイルが重くなる)
// #include <boost/multiprecision/cpp_int.hpp>
// using mll = boost::multiprecision::cpp_int;
// 汎用マクロ
#define ALLOF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define FOREACH(i,q) for (auto &i : q)
template<typename T, typename U> bool chmax(T &a, const U b) { if (a < b) {a = b; return true;} return false; }
template<typename T, typename U> bool chmin(T &a, const U b) { if (a > b) {a = b; return true;} return false; }
constexpr int INF = numeric_limits<int>::max();
constexpr long long LINF = numeric_limits<long long>::max();
constexpr long double EPS = 1e-10L;
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define IIF(q,t,f) ((q) ? (t) : (f))
#define DUMP(q) DUMP_FUNC(q, #q, __FILE__, __LINE__)
template <typename T> void DUMP_PROC(T x) { if (is_integral<T>() || is_floating_point<T>()) cerr << "\e[32m" << x << "\e[m"; else cerr << x; }
template<> void DUMP_PROC<char>(char x) { cerr << "\e[36m\'" << x << "\'\e[m"; }
template<> void DUMP_PROC<string>(string x) { cerr << "\e[33m\"" << x << "\"\e[m"; }
template <typename T, typename U> void DUMP_PROC(pair<T, U> x) { cerr << "{"; DUMP_PROC(x.first); cerr << ", "; DUMP_PROC(x.second); cerr << "}"; }
template <typename ...T, typename U, U... Seq> void DUMP_PROC(tuple<T...> &x, integer_sequence<U, Seq...>) { (void)(int[]){(cerr << ((const char*[]){"", ", "})[!!Seq] << (DUMP_PROC(get<Seq>(x)), ""), 0)...}; }
template <typename ...T> void DUMP_PROC(tuple<T...> x) {cerr << "{"; DUMP_PROC(x, index_sequence_for<T...>()); cerr << "}";}
template <typename T> void DUMP_PROC(vector<T> x) { cerr << "["; for (auto &xi : x) { DUMP_PROC(xi); cerr << (&xi != &*x.rbegin()?", ":""); } cerr << "]"; }
template <typename T> void DUMP_FUNC(T x, const char* name, const char* fn, int ln) { cerr << "\e[32m[DEBUG]\e[m " << name << ": "; DUMP_PROC(x); cerr << " @ " << fn << "(" << ln << ")" << endl; }
// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
// 標準入出力
struct qin { // query input
size_t sz;
qin(size_t _sz = 1) : sz(_sz) {}
template <typename T> operator T () const { T a; cin >> a; return a; }
template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
qin in1; // input one
template <typename T> void say(const T x, const char* end = "\n") { cout << x << end; }
void say(const ld x, const char* end = "\n") { cout << setprecision(30) << x << end; }
template <typename T> void say(const vector<T> x, const char* sep = " ", const char* end = "\n") { REP(i, x.size()) { cout << x[i] << (i+1 == i_len ? end : sep); } }
template <typename T> void say(const vector<vector<T>> x, const char* sep = " ", const char* end = "\n") { REP(i, x.size()) { say(x[i], sep, end); } }
// モジュール
// [[LIBRARY]] marathon.cpp xor128.cpp
// [Inclusion] xor128.cpp
// XORShift 擬似乱数発生器
uint32_t xor128(void){
static uint32_t x = 123456789;
static uint32_t y = 362436069;
static uint32_t z = 521288629;
static uint32_t w = 88675123;
uint32_t t;
t = x ^ (x << 11);
x = y; y = z; z = w;
return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}
inline double rand_uniform(void) { return (double)xor128() / 0x100000000LL; }
template <typename T>
inline T rand_range(T min, T max) { return min + xor128() % (max - min + 1); }
inline bool rand_prob(double p) { return rand_uniform() < p; }
// [Inclusion] marathon.cpp
// 依存関係じゃないけどよほどでなければ一緒に使うのでxor128.cppを入れる
// マラソン用モジュール
namespace marathon {
clock_t start_clock;
constexpr double time_limit = 2; // 実行時間[s]より0.1ms程度余裕をあける
constexpr double time_limit_inv = 1.0 / time_limit;
constexpr double CLOCKS_PER_SEC_INV = 1.0 / CLOCKS_PER_SEC;
inline double nowtime() { return CLOCKS_PER_SEC_INV * (clock() - start_clock); }
inline bool intime() { return nowtime() < time_limit; }
inline double progress() { return nowtime() * time_limit_inv; }
struct preexec_dummy {
preexec_dummy() {
start_clock = clock();
}
} preexec_dummy_instance;
}
// [[/LIBRARY]]
constexpr ll d = 365;
constexpr ll z = 26;
ll calc_score(const vector<ll> &p, const vector<ll> &c, const vector<vector<ll>> &s) {
ll score = 0;
vector last(z, -1);
REP(i, d) {
ll j = p[i];
score += s[i][j];
score -= (i - last[j]) * (i - last[j] - 1) / 2 * c[j];
last[j] = i;
}
REP(j, z) {
const ll x = d-1 - last[j];
score -= x * (x + 1) / 2 * c[j];
}
return score;
}
// void mutate(vector<ll> &p, const vector<ll> &c, const vector<vector<ll>> &s) {
// ll i = xor128() % d;
// ll j = xor128() % z;
// p[i] = j;
// }
void output(const vector<ll> &ans) {
FOREACH(x, ans) {
say(x + 1);
}
}
// 処理内容
int main() {
ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
cin.tie(nullptr); // インタラクティブ問題ではコメントアウトすること
ll dummy;
cin >> dummy;
vector<ll> c = qin(z);
vector s(d, vector(z, 0LL));
REP(i, d) REP(j, z) cin >> s[i][j];
vector ans(d, 0LL);
ll score = -LINF;
// REP(i, 100) {
// vector ans2(d, 0LL);
// REP(i, d) ans2[i] = xor128() % z;
// ll score2 = calc_score(ans2, c, s);
// if (chmax(score, score2)) {
// ans = move(ans2);
// }
// }
REP(i, d) {
ll smax = -LINF;
REP(j, z) {
if (chmax(smax, s[i][j])) {
ans[i] = j;
}
}
}
score = calc_score(ans, c, s);
ll epochs = 0;
while (marathon::progress() <= 0.97) {
REP(ganmodokix, 100) {
ll i = xor128() % d;
ll j = xor128() % z;
ll jprev = ans[i];
ans[i] = j;
ll score2 = calc_score(ans, c, s);
if (score < score2) {
score = score2;
} else {
ans[i] = jprev;
}
epochs++;
}
}
DUMP(tuple(score, epochs));
output(ans);
}
Submission Info
Judge Result
Set Name |
test_ALL |
Score / Max Score |
93962619 / 365000000 |
Status |
|
Set Name |
Test Cases |
test_ALL |
test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt |
Case Name |
Status |
Exec Time |
Memory |
test_00.txt |
AC |
1953 ms |
3780 KB |
test_01.txt |
AC |
1946 ms |
3664 KB |
test_02.txt |
AC |
1954 ms |
3740 KB |
test_03.txt |
AC |
1946 ms |
3756 KB |
test_04.txt |
AC |
1950 ms |
3552 KB |
test_05.txt |
AC |
1951 ms |
3592 KB |
test_06.txt |
AC |
1954 ms |
3612 KB |
test_07.txt |
AC |
1952 ms |
3660 KB |
test_08.txt |
AC |
1951 ms |
3708 KB |
test_09.txt |
AC |
1955 ms |
3712 KB |
test_10.txt |
AC |
1953 ms |
3664 KB |
test_11.txt |
AC |
1953 ms |
3740 KB |
test_12.txt |
AC |
1953 ms |
3556 KB |
test_13.txt |
AC |
1947 ms |
3608 KB |
test_14.txt |
AC |
1950 ms |
3684 KB |
test_15.txt |
AC |
1946 ms |
3648 KB |
test_16.txt |
AC |
1951 ms |
3680 KB |
test_17.txt |
AC |
1948 ms |
3664 KB |
test_18.txt |
AC |
1950 ms |
3668 KB |
test_19.txt |
AC |
1952 ms |
3652 KB |
test_20.txt |
AC |
1952 ms |
3616 KB |
test_21.txt |
AC |
1949 ms |
3704 KB |
test_22.txt |
AC |
1952 ms |
3760 KB |
test_23.txt |
AC |
1951 ms |
3668 KB |
test_24.txt |
AC |
1946 ms |
3652 KB |
test_25.txt |
AC |
1946 ms |
3592 KB |
test_26.txt |
AC |
1953 ms |
3668 KB |
test_27.txt |
AC |
1948 ms |
3752 KB |
test_28.txt |
AC |
1953 ms |
3744 KB |
test_29.txt |
AC |
1948 ms |
3612 KB |
test_30.txt |
AC |
1952 ms |
3728 KB |
test_31.txt |
AC |
1948 ms |
3616 KB |
test_32.txt |
AC |
1951 ms |
3668 KB |
test_33.txt |
AC |
1950 ms |
3760 KB |
test_34.txt |
AC |
1950 ms |
3592 KB |
test_35.txt |
AC |
1948 ms |
3776 KB |
test_36.txt |
AC |
1952 ms |
3756 KB |
test_37.txt |
AC |
1951 ms |
3664 KB |
test_38.txt |
AC |
1951 ms |
3608 KB |
test_39.txt |
AC |
1946 ms |
3652 KB |
test_40.txt |
AC |
1946 ms |
3684 KB |
test_41.txt |
AC |
1947 ms |
3652 KB |
test_42.txt |
AC |
1951 ms |
3756 KB |
test_43.txt |
AC |
1954 ms |
3780 KB |
test_44.txt |
AC |
1953 ms |
3648 KB |
test_45.txt |
AC |
1954 ms |
3684 KB |
test_46.txt |
AC |
1954 ms |
3700 KB |
test_47.txt |
AC |
1946 ms |
3780 KB |
test_48.txt |
AC |
1950 ms |
3556 KB |
test_49.txt |
AC |
1957 ms |
3680 KB |