CSES - Datatähti 2024 alku - Results
Submission details
Task:Monistus
Sender:cylaps
Submission time:2023-11-09 00:56:00 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:8:2: error: #error linux
    8 | #error linux
      |  ^~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:33:14: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   (void)write(STDOUT_FILENO, s, l);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~

Code

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#ifdef WIN32
#error windows
#endif
#ifdef __linux__
#error linux
#endif
#ifdef __MINGW32__
#error mingw
#endif

typedef unsigned char u1;

int main() {

  u1 s[500000];

  unsigned long l = read(STDIN_FILENO, s, 20);

  for (u1 *c = s; *c != '\n';) {
    if (*c - (u1)'0' < 9) {
      unsigned long n = *c - '0';
      memmove(c + n, c + 1, l - (unsigned long)(c - s) - 1);
      memcpy(c, c + n, n);
      l += n;
    } else {
      c++;
    }
  }

  (void)write(STDOUT_FILENO, s, l);

  return 0;
}