제출 #220351

#제출 시각아이디문제언어결과실행 시간메모리
220351giorgikob말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include "horses.h" typedef long long ll; const int mod = 1e9+7; int jump[1000000]; int beg[1000000]; int get_idx(int l,int r){ if(l == r){ return l; } int mid = l+r; mid >>= 1; int x = get_idx(l,mid); int y = get_idx(mid+1,r); ll cnt = 1; for(int i = x+1; i <= y; i++){ if(jump[i] != -1){ i = jump[i]; continue; } cnt *= X[i]; if(cnt > Y[x]){ break; } } return (cnt > Y[x]) ? y : x; } ll calc(int pos){ ll cnt = 1; for(int i = 0; i < pos; i++){ cnt *= X[i]; cnt %= mod; } cnt *= Y[pos]; cnt %= mod; return cnt; } void go(){ for(int i = 0; i < N; i++){ if(X[i] == 1){ int l = i; while(i+1 < N && X[i+1] == 0) i++; while(l != i) jump[l] = i, l++; } } } int init(int N, int X[], int Y[]) { for(int i = 0; i < N; i++){ jump[i] = -1; beg[i] = -1; } go(); int idx = get_idx(0,N); return calc(idx); } int updateX(int pos, int val) { X[pos] = val; go(); int idx = get_idx(0,N); return calc(idx); } int updateY(int pos, int val) { Y[pos] = val; int idx = get_idx(0,N); return calc(idx); } ll calc(int pos){ ll cnt = 1; for(int i = 0; i < pos; i++){ cnt *= X[i]; cnt %= mod; } cnt *= Y[i]; cnt %= mod; return cnt; } void go(){ for(int i = 0; i < N; i++){ if(X[i] == 1){ int l = i; while(i+1 < N && X[i+1] == 0) i++; while(l != i) jump[l] = i, l++; } } } int init(int N, int X[], int Y[]) { for(int i = 0; i < N; i++){ jump[i] = -1; beg[i] = -1; } go(); int idx = get_idx(l,r); return calc(idx); } int updateX(int pos, int val) { X[pos] = val; go(); int idx = get_idx(0,N); return calc(idx); } int updateY(int pos, int val) { Y[pos] = val; int idx = get_idx(0,N); return clac(idx); }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int get_idx(int, int)':
horses.cpp:28:24: error: 'X' was not declared in this scope
                 cnt *= X[i];
                        ^
horses.cpp:29:26: error: 'Y' was not declared in this scope
                 if(cnt > Y[x]){
                          ^
horses.cpp:34:23: error: 'Y' was not declared in this scope
         return (cnt > Y[x]) ? y : x;
                       ^
horses.cpp: In function 'll calc(int)':
horses.cpp:40:24: error: 'X' was not declared in this scope
                 cnt *= X[i];
                        ^
horses.cpp:43:16: error: 'Y' was not declared in this scope
         cnt *= Y[pos];
                ^
horses.cpp: In function 'void go()':
horses.cpp:50:28: error: 'N' was not declared in this scope
         for(int i = 0; i < N; i++){
                            ^
horses.cpp:51:20: error: 'X' was not declared in this scope
                 if(X[i] == 1){
                    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:70:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp:59:23: warning: unused parameter 'X' [-Wunused-parameter]
 int init(int N, int X[], int Y[]) {
                       ^
horses.cpp:59:32: warning: unused parameter 'Y' [-Wunused-parameter]
 int init(int N, int X[], int Y[]) {
                                ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:75:9: error: 'X' was not declared in this scope
         X[pos] = val;
         ^
horses.cpp:79:29: error: 'N' was not declared in this scope
         int idx = get_idx(0,N);
                             ^
horses.cpp:81:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:86:9: error: 'Y' was not declared in this scope
         Y[pos] = val;
         ^
horses.cpp:88:29: error: 'N' was not declared in this scope
         int idx = get_idx(0,N);
                             ^
horses.cpp:90:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp: In function 'll calc(int)':
horses.cpp:94:4: error: redefinition of 'll calc(int)'
 ll calc(int pos){
    ^~~~
horses.cpp:37:4: note: 'll calc(int)' previously defined here
 ll calc(int pos){
    ^~~~
horses.cpp:97:24: error: 'X' was not declared in this scope
                 cnt *= X[i];
                        ^
horses.cpp:100:16: error: 'Y' was not declared in this scope
         cnt *= Y[i];
                ^
horses.cpp:100:18: error: 'i' was not declared in this scope
         cnt *= Y[i];
                  ^
horses.cpp: In function 'void go()':
horses.cpp:105:6: error: redefinition of 'void go()'
 void go(){
      ^~
horses.cpp:48:6: note: 'void go()' previously defined here
 void go(){
      ^~
horses.cpp:107:28: error: 'N' was not declared in this scope
         for(int i = 0; i < N; i++){
                            ^
horses.cpp:108:20: error: 'X' was not declared in this scope
                 if(X[i] == 1){
                    ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:116:5: error: redefinition of 'int init(int, int*, int*)'
 int init(int N, int X[], int Y[]) {
     ^~~~
horses.cpp:59:5: note: 'int init(int, int*, int*)' previously defined here
 int init(int N, int X[], int Y[]) {
     ^~~~
horses.cpp:125:27: error: 'l' was not declared in this scope
         int idx = get_idx(l,r);
                           ^
horses.cpp:125:29: error: 'r' was not declared in this scope
         int idx = get_idx(l,r);
                             ^
horses.cpp:127:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp:116:23: warning: unused parameter 'X' [-Wunused-parameter]
 int init(int N, int X[], int Y[]) {
                       ^
horses.cpp:116:32: warning: unused parameter 'Y' [-Wunused-parameter]
 int init(int N, int X[], int Y[]) {
                                ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:130:5: error: redefinition of 'int updateX(int, int)'
 int updateX(int pos, int val) {
     ^~~~~~~
horses.cpp:73:5: note: 'int updateX(int, int)' previously defined here
 int updateX(int pos, int val) {
     ^~~~~~~
horses.cpp:132:9: error: 'X' was not declared in this scope
         X[pos] = val;
         ^
horses.cpp:136:29: error: 'N' was not declared in this scope
         int idx = get_idx(0,N);
                             ^
horses.cpp:138:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:141:5: error: redefinition of 'int updateY(int, int)'
 int updateY(int pos, int val) {
     ^~~~~~~
horses.cpp:84:5: note: 'int updateY(int, int)' previously defined here
 int updateY(int pos, int val) {
     ^~~~~~~
horses.cpp:143:9: error: 'Y' was not declared in this scope
         Y[pos] = val;
         ^
horses.cpp:145:29: error: 'N' was not declared in this scope
         int idx = get_idx(0,N);
                             ^
horses.cpp:147:9: error: 'clac' was not declared in this scope
  return clac(idx);
         ^~~~
horses.cpp:147:9: note: suggested alternative: 'calc'
  return clac(idx);
         ^~~~
         calc