제출 #220355

#제출 시각아이디문제언어결과실행 시간메모리
220355giorgikob말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include "horses.h" typedef long long ll; const int mod = 1e9+7; int jump[1000000], N; int X[1000000], Y[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[]) { N = n; for(int i = 0; i < N; i++){ jump[i] = -1; //beg[i] = -1; X[i] = x[i]; Y[i] = y[i]; } 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 calc(idx); }

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

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:73:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:84: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:93: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:97: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:103:18: error: 'i' was not declared in this scope
         cnt *= Y[i];
                  ^
horses.cpp: In function 'void go()':
horses.cpp:108:6: error: redefinition of 'void go()'
 void go(){
      ^~
horses.cpp:48:6: note: 'void go()' previously defined here
 void go(){
      ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:119: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:119:33: warning: declaration of 'Y' shadows a global declaration [-Wshadow]
 int init(int N, int X[], int Y[]) {
                                 ^
horses.cpp:9:17: note: shadowed declaration is here
 int X[1000000], Y[1000000];
                 ^
horses.cpp:119:33: warning: declaration of 'X' shadows a global declaration [-Wshadow]
 int init(int N, int X[], int Y[]) {
                                 ^
horses.cpp:9:5: note: shadowed declaration is here
 int X[1000000], Y[1000000];
     ^
horses.cpp:119:33: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 int init(int N, int X[], int Y[]) {
                                 ^
horses.cpp:8:20: note: shadowed declaration is here
 int jump[1000000], N;
                    ^
horses.cpp:123:17: error: 'beg' was not declared in this scope
                 beg[i] = -1;
                 ^~~
horses.cpp:128:27: error: 'l' was not declared in this scope
         int idx = get_idx(l,r);
                           ^
horses.cpp:128:29: error: 'r' was not declared in this scope
         int idx = get_idx(l,r);
                             ^
horses.cpp:130:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~
horses.cpp:119:23: warning: unused parameter 'X' [-Wunused-parameter]
 int init(int N, int X[], int Y[]) {
                       ^
horses.cpp:119: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:133:5: error: redefinition of 'int updateX(int, int)'
 int updateX(int pos, int val) {
     ^~~~~~~
horses.cpp:76:5: note: 'int updateX(int, int)' previously defined here
 int updateX(int pos, int val) {
     ^~~~~~~
horses.cpp:141: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:144:5: error: redefinition of 'int updateY(int, int)'
 int updateY(int pos, int val) {
     ^~~~~~~
horses.cpp:87:5: note: 'int updateY(int, int)' previously defined here
 int updateY(int pos, int val) {
     ^~~~~~~
horses.cpp:150:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return calc(idx);
         ~~~~^~~~~