Submission #1056847

#TimeUsernameProblemLanguageResultExecution timeMemory
1056847tkvinhtruongquangA Huge Tower (CEOI10_tower)C++14
100 / 100
74 ms8260 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define pf push_front #define sz(x) int(x.size()) #define all(x) x.begin(), x.end() #define clz __builtin_clz #define popcount __builtin_popcount #define lb(x) lower_bound(x) #define ub(x) upper_bound(x) #define loop(i, j, n, k) for(int i = j; i <= n; i += k) #define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0) template <typename T> inline void print(T x) { cerr << x << endl; } template <typename T> inline void print(vector <T> x) { cerr << '['; loop(i, 0, sz(x) - 2, 1) cerr << x[i] << ", "; cerr << x.back() << ']' << endl; } template <typename T> inline bool maximize(T &a, const T &b) { return a < b ? (a = b) : 0; } template <typename T> inline bool minimize(T &a, const T &b) { return a > b ? (a = b) : 0; } using ll = long long; using vi = vector<int>; using pii = pair<int, int>; using pss = pair<string, string>; using vll = vector<ll>; using pll = pair<ll, ll>; #define debug(x) cerr << #x << " = "; print(x) void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); freopen("error.txt", "w", stderr); } const int mod = 1e9 + 9; namespace sub1 { int n; int k; vi arr; vi per; void input(int _k, vi &_arr) { arr = _arr; k = _k; n = sz(arr); loop(i, 0, n - 1, 1) per.pb(i); } void solve() { int ans = 0; do { bool check = true; loop(i, 1, n - 1, 1) { if(arr[per[i]] > arr[per[i - 1]] + k) { check = false; break; } } ans += check; } while(next_permutation(all(per))); cout << ans; } } int main() { // setIO("task"); fast; int n, k; cin >> n >> k; vi arr(n); for(auto &i : arr) cin >> i; sort(all(arr)); int r = 0, sol = 1; loop(l, 0, n - 1, 1) { while(r < n - 1 && arr[r + 1] <= arr[l] + k) ++ r; int dist = r - l + 1; sol = (1LL * sol * dist) % mod; } cout << sol; }

Compilation message (stderr)

tower.cpp: In function 'void setIO(std::string)':
tower.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     freopen("error.txt", "w", stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...