Submission #168105

#TimeUsernameProblemLanguageResultExecution timeMemory
168105GioChkhaidzeWeighting stones (IZhO11_stones)C++14
0 / 100
2 ms256 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N=1e5+5; ll n,idx,type,A,B,G[N][3]; void Upd(int x,int type) { while (x<=n) { G[x][type]++; x+=(x & -x); } } ll Get(int x,int type) { ll res=G[0][type]; while (x>0) { res+=G[x][type]; x-=(x & -x); } return res; } main () { scanf("%d",&n); G[0][1]=G[0][2]=1; for (int i=1; i<=n; i++) { scanf("%d%d",&idx,&type); if (type==1) { A+=Get(idx-1,2); B+=Get(n,2)-Get(idx,2); } else { B+=Get(idx-1,1); A+=Get(n,1)-Get(idx,1); } Upd(idx,type); if (A>B) printf(">\n"); else if (A<B) printf("<\n"); else printf("?\n"); } }

Compilation message (stderr)

stones.cpp:22:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
stones.cpp: In function 'int main()':
stones.cpp:23:15: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  scanf("%d",&n);
             ~~^
stones.cpp:28:26: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   scanf("%d%d",&idx,&type);
                ~~~~      ^
stones.cpp:28:26: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
stones.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
stones.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&idx,&type);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...