답안 #703048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703048 2023-02-25T19:20:43 Z Ronin13 Martian DNA (BOI18_dna) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long  long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back

using namespace std;
const int nmax = 2000001;
ll dp[nmax][32];
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k, r; cin >> n >> k >> r;
    vector <vector <int> > vec(k + 1);
    int a[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        vec[a[i]].pb(i);
    }
    vector <int> ind(k + 1, -1);
    int mx = 0;
    for(int i = 1;  i <= r; i++){
        int b, q; cin >> b >> q;
        ind[b] = q - 1;
        if(vec[b].size() <= ind[b]){
            cout << "impossible\n";
            return 0;
        }
        mx = max(mx, vec[b][q - 1]);
    }
    int ans = 1e9;
    for(int i = 1; i <= n; i++){
        ans = min(ans, mx - i + 1);
        if(ind[a[i]] != -1){
            ind[a[i]]++;
            if(ind[a[i]] == vec[a[i]].size()) break;
            mx = max(mx, vec[a[i]][ind[a[i]]]);
        }
    }

    else cout << ans;
    return 0;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:27:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   27 |         if(vec[b].size() <= ind[b]){
dna.cpp:38:26: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             if(ind[a[i]] == vec[a[i]].size()) break;
dna.cpp:43:5: error: 'else' without a previous 'if'
   43 |     else cout << ans;
      |     ^~~~