답안 #1026925

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026925 2024-07-18T14:02:13 Z nisanduu 자동 인형 (IOI18_doll) C++14
0 / 100
59 ms 9760 KB
#include "doll.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
void create_circuit(int M, std::vector<int> A) {
  int N = A.size();
  ll inf = 1e9; 
  std::vector<int> C(M + 1,inf);
  map<int,int> mp;
  vector<int> X,Y;
  vector<int> unused;
  int sz = A.size();
  
  int crMinus = -1;
  C[0] = crMinus;
  Y.push_back(A[0]);
  X.push_back(crMinus);
  crMinus--;
  vector<int> tmp = A;
  tmp.push_back(0);
  
  int ind = 1;
  
  for(int i=0;i<(tmp.size()-1);i++){
    if(mp[tmp[i]]){
        int node = Y[mp[tmp[i]]];
        Y[mp[tmp[i]]] = tmp[i+1];
        X[mp[tmp[i]]] = node;
    }else{
        C[tmp[i]] = crMinus;
        Y.push_back(tmp[i+1]);
        X.push_back(crMinus);
        mp[tmp[i]] = ind;
        ind++;
        crMinus--;
    }
  }
  for(int i=0;i<(M+1);i++){
      if(C[i]==inf){
          unused.push_back(i);
      }
  }
  unused.push_back(0);
  sz = unused.size();
  for(int i=0;i<(sz-1);i++){
      C[unused[i]] = unused[i+1];
  }
  
//   if(sz>0){
//       C[unused[sz-1]] = crMinus;
//       Y.push_back(0);
//       X.push_back(crMinus);
//   }
  
  //std::vector<int> X(N), Y(N);
  answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i=0;i<(tmp.size()-1);i++){
      |               ~^~~~~~~~~~~~~~~
doll.cpp:8:7: warning: unused variable 'N' [-Wunused-variable]
    8 |   int N = A.size();
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 41 ms 7516 KB Output is correct
3 Correct 37 ms 6732 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 2004 KB Output is correct
6 Correct 59 ms 9760 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 41 ms 7516 KB Output is correct
3 Correct 37 ms 6732 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 2004 KB Output is correct
6 Correct 59 ms 9760 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 41 ms 7516 KB Output is correct
3 Correct 37 ms 6732 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 7 ms 2004 KB Output is correct
6 Correct 59 ms 9760 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB wrong motion
2 Halted 0 ms 0 KB -