Submission #168105

# Submission time Handle Problem Language Result Execution time Memory
168105 2019-12-11T11:46:00 Z GioChkhaidze Weighting stones (IZhO11_stones) C++14
0 / 100
2 ms 256 KB
#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

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 time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -