답안 #139339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139339 2019-07-31T15:00:16 Z wilwxk 자동 인형 (IOI18_doll) C++14
18 / 100
26 ms 1856 KB
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+5;
map<int, int> mp;
int faz[MAXN*2];
vector<int> c, x, y, quero;
int n, m, cont;

void debug() {
  for(auto cur : c) printf("%d ", cur); cout << endl;
  for(auto cur : x) printf("%d ", cur); cout << endl;
  for(auto cur : y) printf("%d ", cur); cout << endl;
}

void decompoe(int val) {
  mp[1]=val;
  int cur=1;
  while(1) {
    int qtd=mp[cur]-2;
    if(qtd<=0) break;
    mp[cur*2]+=qtd/2;
    mp[cur]-=(qtd/2)*2;
    cur*=2;
  }
  for(auto mit : mp) for(int i=0; i<mit.second; i++) quero.push_back(mit.first);
  // for(auto cur : quero) printf("%d ", cur);
  // printf("vla3\n");
}

void create_circuit(int M, std::vector<int> A) {
  n=A.size(); m=M;

  if(n==1) {
    c.push_back(1);
    c.push_back(0);
    answer(c, x, y);
    return;
  }

  decompoe(n);
  c.push_back(1);
  c.push_back(--cont);

  int ult=1;
  for(int i=1; i<quero.size(); i++) {
    // printf("%d cuida do %d\n", cont, quero[i]);
    if(quero[i]!=quero[i-1]) {
      if(cont+2==0) x.push_back(1);
      else x.push_back(cont+2);
      y.push_back(cont-1);
    }
    else {
      if(cont+1==0) x.push_back(1);
      else x.push_back(cont+1);
      y.push_back(cont-1);
    }
    cont--;
  }
  y.back()=0;

  // debug();
  answer(c, x, y);
}

Compilation message

doll.cpp: In function 'void debug()':
doll.cpp:12:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   12 |   for(auto cur : c) printf("%d ", cur); cout << endl;
      |   ^~~
doll.cpp:12:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   12 |   for(auto cur : c) printf("%d ", cur); cout << endl;
      |                                         ^~~~
doll.cpp:13:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |   for(auto cur : x) printf("%d ", cur); cout << endl;
      |   ^~~
doll.cpp:13:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   13 |   for(auto cur : x) printf("%d ", cur); cout << endl;
      |                                         ^~~~
doll.cpp:14:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |   for(auto cur : y) printf("%d ", cur); cout << endl;
      |   ^~~
doll.cpp:14:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   14 |   for(auto cur : y) printf("%d ", cur); cout << endl;
      |                                         ^~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:47:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i=1; i<quero.size(); i++) {
      |                ~^~~~~~~~~~~~~
doll.cpp:46:7: warning: unused variable 'ult' [-Wunused-variable]
   46 |   int ult=1;
      |       ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong Answer: wrong array length
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong Answer: wrong array length
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong Answer: wrong array length
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong Answer: wrong array length
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 17 ms 1344 KB Output is correct
3 Correct 24 ms 1336 KB Output is correct
4 Correct 26 ms 1856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 17 ms 1344 KB Output is correct
3 Correct 24 ms 1336 KB Output is correct
4 Correct 26 ms 1856 KB Output is correct
5 Incorrect 26 ms 1848 KB Wrong Answer: wrong array length
6 Halted 0 ms 0 KB -