답안 #1042184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042184 2024-08-02T15:48:29 Z raphaelp 고대 책들 (IOI17_books) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int64 minimum_walk(int[] p, int S)
{
  int N=p.size();
  int64 ans=0;
  for (int i=0; i<N; i++)
  {
    ans+=abs(i-p[i]);
  }
  vector<int>occ(N);
  for(int i=0; i<N; i++)
  {
    if(occ[i])continue;
    int x=i;
    ans+=2;
    while(!occ[x])
    {
      occ[x]=1;
      x=p[x];
    }
    return ans-2;
  }

Compilation message

books.cpp:5:2: error: extended character   is not valid in an identifier
    5 |   int N=p.size();
      |  ^
books.cpp:6:2: error: extended character   is not valid in an identifier
    6 |   int64 ans=0;
      |  ^
books.cpp:7:2: error: extended character   is not valid in an identifier
    7 |   for (int i=0; i<N; i++)
      |  ^
books.cpp:9:2: error: extended character   is not valid in an identifier
    9 |     ans+=abs(i-p[i]);
      |  ^
books.cpp:9:5: error: extended character   is not valid in an identifier
    9 |     ans+=abs(i-p[i]);
      |    ^
books.cpp:11:2: error: extended character   is not valid in an identifier
   11 |   vector<int>occ(N);
      |  ^
books.cpp:12:2: error: extended character   is not valid in an identifier
   12 |   for(int i=0; i<N; i++)
      |  ^
books.cpp:14:2: error: extended character   is not valid in an identifier
   14 |     if(occ[i])continue;
      |  ^
books.cpp:14:5: error: extended character   is not valid in an identifier
   14 |     if(occ[i])continue;
      |    ^
books.cpp:15:2: error: extended character   is not valid in an identifier
   15 |     int x=i;
      |  ^
books.cpp:15:5: error: extended character   is not valid in an identifier
   15 |     int x=i;
      |    ^
books.cpp:16:2: error: extended character   is not valid in an identifier
   16 |     ans+=2;
      |  ^
books.cpp:16:5: error: extended character   is not valid in an identifier
   16 |     ans+=2;
      |    ^
books.cpp:17:2: error: extended character   is not valid in an identifier
   17 |     while(!occ[x])
      |  ^
books.cpp:17:5: error: extended character   is not valid in an identifier
   17 |     while(!occ[x])
      |    ^
books.cpp:18:2: error: extended character   is not valid in an identifier
   18 |     {
      |  ^
books.cpp:19:2: error: extended character   is not valid in an identifier
   19 |       occ[x]=1;
      |  ^
books.cpp:19:5: error: extended character   is not valid in an identifier
   19 |       occ[x]=1;
      |    ^
books.cpp:19:8: error: extended character   is not valid in an identifier
   19 |       occ[x]=1;
      |      ^
books.cpp:20:2: error: extended character   is not valid in an identifier
   20 |       x=p[x];
      |  ^
books.cpp:20:5: error: extended character   is not valid in an identifier
   20 |       x=p[x];
      |    ^
books.cpp:20:8: error: extended character   is not valid in an identifier
   20 |       x=p[x];
      |      ^
books.cpp:21:2: error: extended character   is not valid in an identifier
   21 |     }
      |  ^
books.cpp:22:2: error: extended character   is not valid in an identifier
   22 |     return ans-2;
      |  ^
books.cpp:22:5: error: extended character   is not valid in an identifier
   22 |     return ans-2;
      |    ^
books.cpp:3:1: error: 'int64' does not name a type; did you mean 'int64_t'?
    3 | int64 minimum_walk(int[] p, int S)
      | ^~~~~
      | int64_t