제출 #1274582

#제출 시각아이디문제언어결과실행 시간메모리
1274582icebearFlooding Wall (BOI24_wall)C++20
0 / 100
1 ms580 KiB
// ~~ icebear ~~ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<int, ii> iii; template<class T> bool minimize(T &a, const T &b) { if (a > b) return a = b, true; return false; } template<class T> bool maximize(T &a, const T &b) { if (a < b) return a = b, true; return false; } #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORR(i,a,b) for(int i=(a); i>=(b); --i) #define REP(i, n) for(int i=0; i<(n); ++i) #define RED(i, n) for(int i=(n)-1; i>=0; --i) #define MASK(i) (1LL << (i)) #define BIT(S, i) (((S) >> (i)) & 1) #define mp make_pair #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define task "icebear" const int MOD = 1e9 + 7; const int inf = 1e9 + 27092008; const ll INF = 1e18 + 27092008; const int N = 5e5 + 5; int n, a[N], b[N], w[N], pref[N], suff[N], power2[N]; void init(void) { cin >> n; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; } void process(void) { power2[0] = 1; FOR(i, 1, n) power2[i] = 1LL * power2[i - 1] * 2 % MOD; vector<int> vals; FOR(i, 1, n) { vals.pb(a[i]); vals.pb(b[i]); } sort(all(vals)); vals.resize(unique(all(vals)) - vals.begin()); int ans = 0; FOR(j, 1, (int)vals.size() - 1) { FOR(i, 1, n) w[i] = (a[i] < vals[j]) + (b[i] < vals[j]); pref[1] = suff[n] = 1; FOR(i, 2, n) pref[i] = 1LL * pref[i - 1] * w[i]; FORR(i, n - 1, 1) suff[i] = 1LL * suff[i + 1] * w[i]; int ways = 0; FOR(i, 2, n - 1) (ways += 1LL * (power2[i - 1] - pref[i - 1]) * (power2[n - i] - suff[i + 1]) * w[i]) %= MOD; (ans += 1LL * ways * (vals[j] - vals[j - 1]) % MOD) %= MOD; } cout << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int tc = 1; // cin >> tc; while(tc--) { init(); process(); } return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen(task".out", "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...