Submission #658923

#TimeUsernameProblemLanguageResultExecution timeMemory
658923Jeff12345121Horses (IOI15_horses)C++14
17 / 100
12 ms8276 KiB
#include <bits/stdc++.h> #include "horses.h" #define REP(i,n) for(int i = 1; i <= (n); i++) using namespace std; #ifdef LOCAL ifstream in("in.in"); ofstream out("out.out"); #endif const int nmax = 1005; int n,x[nmax],y[nmax],inf = (1LL << 60),MOD = 1000000007; int init(int tn, int* tx,int* ty) { n = tn; for (int i = 0; i < n; i++) { x[i] = tx[i]; y[i] = ty[i]; } int horses = 1,max_sol = -inf; for (int i = 0; i < n; i++) { horses = 1LL * horses * x[i] % MOD; max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD); } return max_sol; } int updateX(int pos, int val) { x[pos] = val; int horses = 1,max_sol = -inf; for (int i = 0; i < n; i++) { horses = 1LL * horses * x[i] % MOD; max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD); } return max_sol; } int updateY(int pos, int val) { y[pos] = val; int horses = 1,max_sol = -inf; for (int i = 0; i < n; i++) { horses = 1LL * horses * x[i] % MOD; max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD); } return max_sol; } #ifdef LOCAL /*int tx[nmax],ty[nmax]; int32_t main() { in >> n; for (int i = 0; i < n; i++) { in >> tx[i]; } for (int i = 0; i < n; i++) { in >> ty[i]; } out << init(n,tx,ty) << "\n"; int m; in >> m; for (int i = 0; i < m; i++) { int type,pos,val; in >> type >> pos >> val; if (type == 0) { out << updateX(pos, val); } if (type == 1) { out << updateY(pos,val); } } }*/ #endif

Compilation message (stderr)

horses.cpp:13:34: warning: overflow in conversion from 'long long int' to 'int' changes value from '1152921504606846976' to '0' [-Woverflow]
   13 | int n,x[nmax],y[nmax],inf = (1LL << 60),MOD = 1000000007;
      |                             ~~~~~^~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:24:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   24 |         horses = 1LL * horses * x[i] % MOD;
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:25:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   25 |         max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:34:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   34 |         horses = 1LL * horses * x[i] % MOD;
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:35:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   35 |         max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:45:38: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |         horses = 1LL * horses * x[i] % MOD;
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:46:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |         max_sol = max(1LL * max_sol , 1LL * horses * y[i] % MOD);
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...