제출 #418481

#제출 시각아이디문제언어결과실행 시간메모리
418481jacquesamsel자동 인형 (IOI18_doll)C++14
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; void print_vecint(vector<int>& v) { for (auto x : v) { cout << x << " "; } cout << endl; } void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y); int create_switch(vector<int>& X, vector<int>& Y, vector<int> runOutcomes) { int noOut = runOutcomes.size(); X.push_back(runOutcomes[0]); Y.push_back(runOutcomes[1]); return -(X.size()); } void create_circuit(int M, vector<int> A) { // A.push_back(0); A.insert(A.begin(), {0}); vector<int> X; vector<int> Y; vector<int> C; C.assign(M+1, 0); vector<vector<int>> occurances; occurances.assign(M+1, {}); for (int i = 0; i < A.size(); i++) { if (A[i] != 0) { occurances[A[i]].push_back(A[i+1]); } } unordered_map<int, int> switches; for (int i = 0; i < occurances.size(); i++) { if (occurances[i].size() > 1) { switches.insert({i, create_switch(X, Y, occurances[i])}); C[i] = switches[i]; } } print_vecint(A); int last = 0; bool skip = false; for (int i = 0; i < A.size(); i++) { if (skip) { skip = false; continue; } if (switches.find(A[i+1]) != switches.end()) { C[A[i]] = A[i+1]; skip = true; } else { // cout << "normal: " << A[i+1] << endl; C[A[i]] = A[i+1]; } // print_vecint(C); } answer(C, X, Y); }

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

doll.cpp: In function 'int create_switch(std::vector<int>&, std::vector<int>&, std::vector<int>)':
doll.cpp:14:9: warning: unused variable 'noOut' [-Wunused-variable]
   14 |     int noOut = runOutcomes.size();
      |         ^~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < A.size(); i++) {
      |                     ~~^~~~~~~~~~
doll.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < occurances.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~
doll.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < A.size(); i++) {
      |                     ~~^~~~~~~~~~
doll.cpp:42:9: warning: unused variable 'last' [-Wunused-variable]
   42 |     int last = 0;
      |         ^~~~
#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...