답안 #58828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58828 2018-07-19T15:29:28 Z joaogui1 최후의 만찬 (IOI12_supper) C++14
8 / 100
508 ms 147456 KB
#include "advisor.h"
#include <bits/stdc++.h>
#define ff first
#define ss second

using namespace std;
typedef pair<int, int> pii;

set<pii> s;
int sca[100100];
vector <int> ans;
queue <int> q[100100];

vector <int> dectobin(int n){
  vector<int> r;
  for(int i = 12; i > -1; --i)
    if((1 << i) <= n){
      r.push_back(1);
      n -= (1 << i);
    }
    else  r.push_back(0);
  return r;
}

void ComputeAdvice(int *C, int N, int K, int M){
  vector <int> aux;
  for(int i = 0; i < N; ++i)  q[C[i]].push(-i);
  for(int i = 0; i < N; ++i) q[i].push(-2*N);
  for(int i = 0; i < K; ++i) s.insert(pii(q[i].front(), i));
  for(int i = 0; i < N; ++i){
    if(s.count(pii(q[C[i]].front(), C[i])) != 0){
      s.erase(pii(q[C[i]].front(), C[i]));
      q[C[i]].pop();
      s.insert(pii(q[C[i]].front(), C[i]));
    }
    else{
      ans.push_back(s.begin() -> ss);
      q[C[i]].pop();
      s.erase(s.begin());
      s.insert(pii(q[C[i]].front(), C[i]));
    }
  }
  for(int i = 0; i < ans.size(); ++i){
    aux = dectobin(ans[i]);
    for(int j = 0; j < aux. size(); ++j)
      WriteAdvice(aux[j]);
  }
}
#include "assistant.h"
#include<bits/stdc++.h>

using namespace std;
set <int> scaf;

vector<int> bintodec(unsigned char *A, int R){
  int aux = 0;
  vector<int> r;
  for(int i = 0; i < R && A[i] != 2; ++i){
    aux += (1 << (12 - (i%13)))*(A[i] == 1);
    if((i%13) == 12){
      r.push_back(aux);
      aux = 0;
    }
  }
  return r;
}

void Assist(unsigned char *A, int N, int K, int R){
  int cnt = 0;
  vector<int> rem = bintodec(A, R);
  for(int i = 0; i < K; ++i)  scaf.insert(i);
  for(int i = 0; i < N; ++i){
    int req = GetRequest();
    if(scaf.count(req)) continue;

    else{
      scaf.erase(rem[cnt]);
      scaf.insert(req);
      PutBack(rem[cnt++]);
    }
  }
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:43:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < ans.size(); ++i){
                  ~~^~~~~~~~~~~~
advisor.cpp:45:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0; j < aux. size(); ++j)
                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 135664 KB Output is correct
2 Correct 71 ms 135864 KB Output is correct
3 Correct 74 ms 136352 KB Output is correct
4 Correct 96 ms 136720 KB Output is correct
5 Correct 107 ms 136856 KB Output is correct
6 Correct 112 ms 137048 KB Output is correct
7 Correct 82 ms 137048 KB Output is correct
8 Correct 109 ms 137048 KB Output is correct
9 Correct 95 ms 137048 KB Output is correct
10 Correct 92 ms 137048 KB Output is correct
11 Correct 96 ms 137240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 107 ms 137320 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 349 ms 143664 KB Error - Putting back a color that is not on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 85 ms 143664 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 398 ms 145032 KB Error - Putting back a color that is not on the scaffold
2 Incorrect 412 ms 145072 KB Error - Putting back a color that is not on the scaffold
3 Incorrect 443 ms 145144 KB Error - Putting back a color that is not on the scaffold
4 Incorrect 481 ms 145144 KB Error - Putting back a color that is not on the scaffold
5 Incorrect 461 ms 145144 KB Error - Putting back a color that is not on the scaffold
6 Incorrect 462 ms 145312 KB Error - Putting back a color that is not on the scaffold
7 Incorrect 419 ms 145312 KB Error - Putting back a color that is not on the scaffold
8 Incorrect 439 ms 145312 KB Error - Putting back a color that is not on the scaffold
9 Incorrect 434 ms 145312 KB Error - Putting back a color that is not on the scaffold
10 Incorrect 508 ms 147456 KB Error - Putting back a color that is not on the scaffold