Submission #885382

# Submission time Handle Problem Language Result Execution time Memory
885382 2023-12-09T14:56:13 Z eilouvre Werewolf (IOI18_werewolf) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>

std::vector<int> check_validity(int N, std::vector<int>& X, std::vector<int>& Y, std::vector<int>& S, std::vector<int>& E, std::vector<int>& L, std::vector<int>& R) {
    std::vector<int> A(S.size(), 1);  // Initialize with all trips as possible
    
    std::vector<int> low_populated_cities(N + 1, 0);
    std::vector<int> high_populated_cities(N + 1, 0);
    
    for (int i = 0; i < L.size(); ++i) {
        low_populated_cities[L[i]] += 1;
        high_populated_cities[R[i] + 1] += 1;
    }
    
    for (int i = 1; i <= N; ++i) {
        low_populated_cities[i] += low_populated_cities[i - 1];
        high_populated_cities[i] += high_populated_cities[i - 1];
    }
    
    for (int i = 0; i < S.size(); ++i) {
        int si = S[i];
        int ei = E[i];
        
        int low_count = low_populated_cities[ei] - low_populated_cities[si - 1];
        int high_count = high_populated_cities[ei] - high_populated_cities[si - 1];
        
        if (low_count > high_count) {
            A[i] = 0;
        }
    }
    
    return A;
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>&, std::vector<int>&, std::vector<int>&, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
werewolf.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i = 0; i < L.size(); ++i) {
      |                     ~~^~~~~~~~~~
werewolf.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < S.size(); ++i) {
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccoWPXfb.o: in function `main':
grader.cpp:(.text.startup+0x377): undefined reference to `check_validity(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status