Submission #333892

#TimeUsernameProblemLanguageResultExecution timeMemory
333892beksultan04Simple game (IZhO17_game)C++14
22 / 100
1081 ms1924 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 1e6+12,INF=1e9+7; int a[N],b[N],q[N],dp[N],n,sum; void fun1(int x){ int y; scan1(y) q[x]=y; } int fun2(int x){ int i,p=q[1],ans=0; for (i=2;i<=n;++i){ if (p < x && x < q[i] || p > x && x > q[i])ans++; p=q[i]; } ret ans; } main(){ int m,i,j,k; scan2(n,m) for (i=1;i<=n;++i) scan1(q[i]) while (m--){ int t,z; scan2(t,z) if (t==1)fun1(z); if (t==2)cout <<fun2(z)<<'\n'; } }

Compilation message (stderr)

game.cpp: In function 'long long int fun2(long long int)':
game.cpp:27:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |         if (p < x && x < q[i] ||
      |             ~~~~~~^~~~~~~~~~~
game.cpp: At global scope:
game.cpp:35:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      |      ^
game.cpp: In function 'int main()':
game.cpp:36:13: warning: unused variable 'j' [-Wunused-variable]
   36 |     int m,i,j,k;
      |             ^
game.cpp:36:15: warning: unused variable 'k' [-Wunused-variable]
   36 |     int m,i,j,k;
      |               ^
game.cpp: In function 'void fun1(long long int)':
game.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
game.cpp:20:5: note: in expansion of macro 'scan1'
   20 |     scan1(y)
      |     ^~~~~
game.cpp: In function 'int main()':
game.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
game.cpp:37:5: note: in expansion of macro 'scan2'
   37 |     scan2(n,m)
      |     ^~~~~
game.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
game.cpp:39:9: note: in expansion of macro 'scan1'
   39 |         scan1(q[i])
      |         ^~~~~
game.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
game.cpp:42:9: note: in expansion of macro 'scan2'
   42 |         scan2(t,z)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...