제출 #1127481

#제출 시각아이디문제언어결과실행 시간메모리
1127481MinhTuan11 Martian DNA (BOI18_dna)C++20
100 / 100
32 ms4936 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second const int N = 2e5 + 5; const int K = 1e2 + 5; const int mod = 1e9 + 7; const int inf = 1e18 + 7; #define all(v) (v).begin(), (v).end() #define pii pair<int, int> using namespace std; mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int n, k, r, a[N]; int b[N], c[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); if(ifstream("file.inp")){ freopen("file.inp", "r", stdin); freopen("file.out", "w", stdout); } cin >> n >> k >> r; for(int i = 1; i <= n; i++) cin >> a[i]; memset(b, -1, sizeof b); for(int i = 1, x, y; i <= r; i++) { cin >> x >> y; b[x] = y; } int j = 1, com = 0, res = n + 1; for(int i = 1; i <= n; i++) { c[a[i]]++; if(c[a[i]] == b[a[i]] && b[a[i]] != -1) com++; while(c[a[j]] > b[a[j]] || b[a[j]] == -1) c[a[j++]]--; if(com == r) { res = min(res, i - j + 1); } } if(res == n + 1) cout << "impossible"; else cout << res << '\n'; return 0; } // tuntun

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

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