Submission #363964

#TimeUsernameProblemLanguageResultExecution timeMemory
363964MaisyDoge13A Huge Tower (CEOI10_tower)C++17
30 / 100
1097 ms262148 KiB
#include <iostream> #include <cstdio> #include <vector> #include <utility> #include <cmath> #include <algorithm> #include <array> #include <set> #include <map> #include <climits> using namespace std; #define input "tower.in" #define output "tower.out" #define int long long #define MOD (int)(1e9+9) int n, k; vector<int> a_orig; vector<int> a; int ans=1; bool within(int n1, int n2) { return (n1+k>=n2); } int recurs(vector<bool> vis, int last) { if (find(vis.begin(), vis.end(), 0) == vis.end()) return 1; //for (int x: a) cout << x << ' '; //cout << endl; //for (bool b: vis) cout << b << ' '; //cout << endl; int curr_sum=0; for (int i=0;i<a.size();i++) { if (!within(last, a[i])) { //cout << last << " not within " << a[i] << endl; return curr_sum; } if (!vis[i]) { vis[i] = true; curr_sum += recurs(vis, a[i]); vis[i] = false; } } return curr_sum; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(input, "r", stdin); //freopen(output, "w", stdout); cin >> n >> k; a_orig.reserve(n); a.reserve(n); int x; for (int i=0;i<n;i++) { cin >> x; a_orig.push_back(x); } sort(a_orig.begin(), a_orig.end()); a.push_back(a_orig[0]); for (int i=1;i<n;i++) { if (!within(a_orig[i-1], a_orig[i])) { ans *= recurs(vector<bool>(a.size(), 0), INT_MAX); a.clear(); } a.push_back(a_orig[i]); } ans *= recurs(vector<bool>(a.size(), 0), INT_MAX); cout << ans % MOD; }

Compilation message (stderr)

tower.cpp: In function 'long long int recurs(std::vector<bool>, long long int)':
tower.cpp:32:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~
#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...