제출 #635603

#제출 시각아이디문제언어결과실행 시간메모리
635603nayhzJob Scheduling (CEOI12_jobs)C++17
0 / 100
571 ms63804 KiB
// CEOI 2012 Dau 1 Job Scheduling #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define lck cout << "ick bmi 32.9\n" #define cam_cs cout << "ick orz\n" #define orz(x) cout << (x) << " orz\n" #define pii pair<int, int> #define pll pair<long long, long long> #define pcc pair<char, char> #define ll long long #define ull unsigned long long #define ld long double #define int unsigned long long #define vi vector<int> #define vll vector<long long> #define vd vector<double> #define vpii vector<pair<int, int>> #define vpll vector<pair<long long, long long>> #define vc vector<char> #define vsc vector<string> #define vb vector<bool> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define yes() cout << "YES\n" #define no() cout << "NO\n" #define impossible() cout << "Impossible\n" template<typename T, typename V> inline void print (const std::pair<T, V> &x) {std::cout << x.first << ' ' << x.second << '\n';} template<typename T> inline void print (const T &x) {std::cout << x << '\n';} template<typename T> inline void print (std::vector<T> &x) {for (auto &y : x) std::cout << y << " "; std::cout << '\n';} inline void print () {std::cout << '\n';} using namespace std; const ld pi = acos(-1); const ld eps = 1e-9; const ll mod = 1000000007; const ll inf = 1000000007; clock_t T, NT; inline double get_time() {NT = clock() - T; return (double)(NT) / CLOCKS_PER_SEC;} void file_io (string x); /* >>>>>>>>>>>>>>>>>>>>>>>>>>END OF TEMPLATE HEADER<<<<<<<<<<<<<<<<<<<<<<<< */ void solve (int &tc) { int n, d, m; cin >> n >> d >> m; vpii a(m); for (int i = 0; i < m; i++) {cin >> a[i].fi; a[i].se = i + 1;} sort(all(a)); vector<vi> ans; int l = 1, r = m, mid; function<pair<bool, vector<vi>> ()> check = [&] () { vector<vi> ret(n); int cnt = 0; for (int day = 1; day <= n; day++) { for (int i = 0; i < mid; i++) { if (a[i].fi > day) break; if (a[cnt].fi + d >= day){ ret[day - 1].pb(a[cnt++].se); } else return mp(false, ret); if (cnt == m) { return mp(true, ret); } } } return mp(false, ret); }; while (l < r) { mid = l + ((r - l) >> 1); pair<bool, vector<vi>> ret = check(); if (ret.fi) { r = mid, ans = ret.se; } else l = mid + 1; } cout << l << '\n'; for (auto &x : ans) x.pb(0); for (int i = 0; i < n; i++) print(ans[i]); cout << "0\n"; } signed main () { cin.tie()->sync_with_stdio(false); T = clock(); srand(time(NULL)); // file_io(""); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { solve(i); // if (i != t) cout << '\n'; } // while (true) {solve(t); t++;} return 0; } void file_io (string x = "x") { string i = x + ".in"; freopen(i.c_str(), "r", stdin); string o = x + ".out"; freopen(o.c_str(), "w", stdout); }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'void file_io(std::string)':
jobs.cpp:124:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  124 |  freopen(i.c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:126:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  126 |  freopen(o.c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...