Submission #1285732

#TimeUsernameProblemLanguageResultExecution timeMemory
1285732ggillianjiang코끼리 (Dancing Elephants) (IOI11_elephants)C++20
0 / 100
1 ms332 KiB
#include "elephants.h"
#include <cstdio>
#include <vector>
#include <utility>

using namespace std;

#define loop(s) for(int a = 0; a < s; ++a)
using vec_t = vector<int>;
using p_t = pair<int, pair<int, int> >;
using vp_t = vector< p_t >;
using vv_t = vector< vector<int> >;
int n, l, least;
vec_t x;
vec_t pos;
vp_t cameras;

vv_t frames;

void init(int N, int L, int X[])
{
  int M, i, y;
  n=N;
  l=L;

  loop(sizeof(*X)/sizeof(X[0])){
    frames[X[a]/l].push_back(X[a]);
    if(X[a]/l != X[a-1]/l) least++;
  }

  printf("%d", least);

  loop(M){
    scanf("%d %d", i, y);
    update(i,y);
  }

}

int update(int i, int y)
{
    bool empty;
    loop(frames[i/l].size()){
      if(frames[i/l][a]==-1) continue;
      else if(frames[i/l][a]==i && a==frames[i/l].size()-1) frames[i/l].pop_back();
      else if(frames[i/l][a]==i) frames[i/l][a] = -1;
      else empty = false;
    }

    if(empty) least--;

    frames[y/l].push_back(y);

    if(frames[y/l]!=frames[i/l]) least++;
    
    
    printf("%d", least);

    return least;
}

Compilation message (stderr)

elephants.cpp: In function 'void init(int, int, int*)':
elephants.cpp:34:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'int' [-Wformat=]
   34 |     scanf("%d %d", i, y);
      |            ~^      ~
      |             |      |
      |             int*   int
elephants.cpp:34:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'int' [-Wformat=]
   34 |     scanf("%d %d", i, y);
      |               ~^      ~
      |                |      |
      |                int*   int
elephants.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d %d", i, y);
      |     ~~~~~^~~~~~~~~~~~~~~
#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...