제출 #1290898

#제출 시각아이디문제언어결과실행 시간메모리
1290898moha1111 Martian DNA (BOI18_dna)C++20
100 / 100
34 ms5100 KiB
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #include <cstdio> #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define all(a) a.begin() , a.end() const long long mod = 1000000007; using namespace std; #define int long long using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_multiset; void usaco(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve() { int n , k , r; cin >> n >> k >> r; int a[n]; vector<int> cun(k + 1 , 0); for(int i = 0 ; i < n ; i++) cin >> a[i]; for(int i = 0 ; i < r ; i++) { int b , c; cin >> b >> c; cun[b] += c; } int st = 0 , en = n , ans = -1; while(st <= en) { vector<int> cur = cun; int ok = 0 , rem = accumulate(all(cur) , 0); int mid = (st + en) / 2; for(int i = 0 ; i < mid ; i++) { if(cur[a[i]] > 0) rem--; cur[a[i]]--; } ok |= (rem == 0); for(int i = mid ; i < n ; i++) { if(cur[a[i - mid]] >= 0) rem++; cur[a[i - mid]]++; if(cur[a[i]] > 0) rem--; cur[a[i]]--; ok |= (rem == 0); } if(ok) ans = mid , en = mid - 1; else st = mid + 1; } if(ans == -1) cout << "impossible"; else cout << ans; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // usaco("triangles"); int t = 1; // cin >> t; while(t--) solve(); }

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

dna.cpp: In function 'void usaco(std::string)':
dna.cpp:15:16: 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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dna.cpp:16:16: 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...