제출 #581033

#제출 시각아이디문제언어결과실행 시간메모리
581033maskrioA Huge Tower (CEOI10_tower)C++17
20 / 100
1095 ms262144 KiB
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <sstream> #include <queue> #include <deque> #include <bitset> #include <iterator> #include <list> #include <stack> #include <map> #include <set> #include <functional> #include <numeric> #include <utility> #include <limits> #include <time.h> #include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <iomanip> using namespace std; #define ll long long #define deb(x) cout << #x << " = " << x << endl; #define pb push_back #define F first #define S second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define mp make_pair #define fo(i, j) for(i=0;i<j;i++) #define Fo(i, k, n) for(i=k;k<n?i<n:i>n;k<n?i++:i--) #define MOD ((int)1e9+7) #define imax INT_MAX #define imin INT_MIN #define PI 3.1415926535897932384626433832795 #define tr(it, x) for(auto it = x.begin(); it != x.end(); it++) #define trr(it, x) for(auto it = x.rbegin(); it != x.rend(); it+) #define sortall(x) sort(all(x)) typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<string> VS; typedef vector<PII> VII; typedef vector<VI> VVI; typedef map<int,int> MPII; template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; } template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; } void WVI(VI ar){ int i; fo(i, ar.size()){ cout << ar[i] << " "; }cout << endl; } void setIO(string name = ""){ ios_base::sync_with_stdio(0); cin.tie(0); if(name.size()>0){ freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } const int mxN = 1e5+5; const int INF = 1e9+50; //************************************************************** int n,d; VI ar; ll ptry(ll x, vector<bool> used){ bool cek = true; ll ret = 0; for(int i=0;i<n;i++) { if(used[i]) continue; cek = false; //cout << ar[i] << " " << x << endl; if(ar[i] > x + d) continue; used[i] = true; ret += ptry(ar[i], used) % MOD; used[i] = false; } if(cek) { return 1; } return ret%MOD; } void solve(){ cin >> n >> d; vector<bool> used(n,false); ar.resize(n); for(int i=0;i<n;i++) cin >> ar[i]; sort(ar.begin(), ar.end(), greater<int>()); //for(int a : used) cout << a << " "; cout << endl; ll a = ptry(1e11, used); cout << a; } int main(){ string name = ""; setIO(name); int test_cases = 1; //cin >> test_cases; while(test_cases--) { solve(); } return 0; }

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

tower.cpp: In function 'void WVI(VI)':
tower.cpp:38:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 | #define fo(i, j) for(i=0;i<j;i++)
......
   60 |     fo(i, ar.size()){
      |        ~~~~~~~~~~~~        
tower.cpp:60:5: note: in expansion of macro 'fo'
   60 |     fo(i, ar.size()){
      |     ^~
tower.cpp: In function 'void setIO(std::string)':
tower.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tower.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen((name + ".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...