답안 #1008746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008746 2024-06-26T17:29:04 Z Rolo678 Labels (NOI20_labels) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >>n;
  vector<int>d(n);
  for(int i = 1;i<n;i++)
  {
    cin >>d[i];
  }
  
  
  int num = 0;
  int ans = 0;
  for(int i = 1;i<=n;i++)
  {
      flag = true;
      int k = i;
      for(int j = 1;j<n;j++)
      {
        if(d[i]+k > n)
        {
           flag = false;
          break;
        }
        else
        {
           k+= d[i];
        }
        num += flag;
        if(flag)ans = i;
      }
  }
    
    if(num != 1)
    {
      cout << -1 << '\n';
    }
    else
    {
      int k = i;
      cout << i << ' ';
      for(int j:d)
      {
        k+= j;
        cout << k << ' ';
      }
    }
    
  
}

Compilation message

Labels.cpp: In function 'int main()':
Labels.cpp:19:7: error: 'flag' was not declared in this scope
   19 |       flag = true;
      |       ^~~~
Labels.cpp:43:15: error: 'i' was not declared in this scope
   43 |       int k = i;
      |               ^