Submission #646804

#TimeUsernameProblemLanguageResultExecution timeMemory
646804VitaliyFSFloppy (RMI20_floppy)C++17
Compilation error
0 ms0 KiB
#include <algorithm> #include <assert.h> #include <stdio.h> #include <stdlib.h> #include "floppy.h" #define NMAX 100000 #define MMAX 100000 int subtask_id, N, M; std::vector<int> v, sorted_v; std::vector<int> a, b; std::vector<int> correct_answers; // Print score to stdout and exit. void score_and_exit(const double pts, const char *verdict) { fprintf(stderr, "%s", verdict); fprintf(stdout, "%f", pts); exit(0); } // Contestant sent too many bits. void too_many_bits() { score_and_exit(0, "Too many stored bits!"); } // Contestant did not send any bits. void misformatted_stored_bits() { score_and_exit(0, "Misformatted stored bits or save_to_floppy not called!"); } // Contestant did not call the answer function. void answer_not_provided() { score_and_exit(0, "Answer not provided!"); } // Contestant sent a wrong answer. void wrong_answer() { score_and_exit(0, "Wrong answer to query!"); } // Contestant sent a correct answer. void correct_answer() { score_and_exit(1, "OK!"); } void read_test() { assert(scanf("%d", &subtask_id) == 1); assert(scanf("%d%d", &N, &M) == 2); assert(1 <= N && N <= NMAX); assert(0 <= M && M <= MMAX); v.resize(N); for (int i = 0; i < N; ++i) { assert(scanf("%d", &v[i]) == 1); } // Check all values are distinct. sorted_v.resize(N); for (int i = 0; i < N; ++i) { sorted_v[i] = v[i]; } std::sort(sorted_v.begin(), sorted_v.end()); for (int i = 0; i + 1 < N; ++i) { assert(sorted_v[i] < sorted_v[i + 1]); } a.resize(M); b.resize(M); correct_answers.resize(M); for (int i = 0; i < M; ++i) { assert(scanf("%d%d%d", &a[i], &b[i], &correct_answers[i]) == 3); assert(0 <= a[i] && a[i] <= correct_answers[i] && correct_answers[i] <= b[i] && b[i] < N); } } void save_to_floppy(const std::string &bits) { std::vector<int> contestant_answers = solve_queries(subtask_id, N, bits, a, b); for (int i = 0; i < M; ++i) { if (contestant_answers[i] != correct_answers[i]) { wrong_answer(); } } correct_answer(); exit(0); } int main(int argc, char **argv) { // Read input data. read_test(); // Send subtask_id, v. read_array(subtask_id, v); answer_not_provided(); return 0; }

Compilation message (stderr)

stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccTVii76.o: in function `save_to_floppy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
stub.cpp:(.text+0x1a0): multiple definition of `save_to_floppy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'; /tmp/cczU7Hf4.o:floppy.cpp:(.text+0x480): first defined here
/usr/bin/ld: /tmp/ccTVii76.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cczU7Hf4.o:floppy.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cczU7Hf4.o: in function `save_to_floppy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
floppy.cpp:(.text+0x4ba): undefined reference to `solve_queries(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/cczU7Hf4.o: in function `main':
floppy.cpp:(.text.startup+0x1d): undefined reference to `read_array(int, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/ccTVii76.o: in function `run2()':
stub.cpp:(.text+0x698): undefined reference to `solve_queries(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/ccTVii76.o: in function `run1()':
stub.cpp:(.text+0xb1d): undefined reference to `read_array(int, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status