Submission #419807

#TimeUsernameProblemLanguageResultExecution timeMemory
419807SuhaibSawalha1Mechanical Doll (IOI18_doll)C++17
0 / 100
1 ms332 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; void create_circuit(int M, vector<int> A) { int N = A.size(); vector<int> C(M + 1), X(1), Y(1), cnt(M + 1); vector<vector<int>> a(3); for (int i : A) { ++cnt[i]; } for (int i = 1; i <= M; ++i) { a[cnt[i]].push_back(i); } if (a[2].empty()) { C[0] = -1; X[0] = -1; } else { C[0] = X[0] = a[2][0]; for (int i = 0; i < a[2].size() - 1; ++i) { C[a[2][i]] = a[2][i + 1]; } C[a[2].back()] = -1; } if (a[1].empty()) { } else { Y[0] = a[1][0]; for (int i = 0; i < a[1].size() - 1; ++i) { C[a[1][i]] = a[1][i + 1]; } C[a[1].back()] = 0; } answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < a[2].size() - 1; ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~
doll.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < a[1].size() - 1; ++i) {
      |                     ~~^~~~~~~~~~~~~~~~~
doll.cpp:6:7: warning: unused variable 'N' [-Wunused-variable]
    6 |   int N = A.size();
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...