Submission #930970

#TimeUsernameProblemLanguageResultExecution timeMemory
930970guagua0407A Huge Tower (CEOI10_tower)C++17
100 / 100
61 ms3676 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } inline char readchar() { const int S = 1<<20; // buffer size static char buf[S], *p = buf, *q = buf; if(p == q && (q = (p=buf)+fread(buf,1,S,stdin)) == buf) return EOF; return *p++; } #include <cstdio> inline int nextint() { int x = 0, c = readchar(), neg = false; while(('0' > c || c > '9') && c!='-' && c!=EOF) c = readchar(); if(c == '-') neg = true, c = readchar(); while('0' <= c && c <= '9') x = x*10 + (c^'0'), c = readchar(); if(neg) x = -x; return x; // returns 0 if EOF } const int mod=1e9+9; int main() {_ int n,d; n=nextint(); d=nextint(); vector<int> a(n); for(int i=0;i<n;i++){ a[i]=nextint(); } sort(all(a)); int l=0; int ans=1; for(int r=0;r<n;r++){ while(a[l]+d<a[r]){ l++; } ans=1ll*ans*(r+1-l)%mod; } cout<<ans<<'\n'; return 0; } //maybe its multiset not set //yeeorz //laborz

Compilation message (stderr)

tower.cpp: In function 'void setIO(std::string)':
tower.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...