답안 #345539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345539 2021-01-07T14:42:03 Z Kerim Examination (JOI19_examination) C++17
0 / 100
3000 ms 10160 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int a[MAXN],b[MAXN],c[MAXN],id[MAXN];
int x[MAXN],y[MAXN],z[MAXN],di[MAXN];
vector<int>v;
int en[MAXN],bel[MAXN],cur,sz,n,q;
bool cmp(int xx,int yy){
	return (a[xx]>a[yy]);	
}
bool cmp1(int xx,int yy){
	return (x[xx]>x[yy]);	
}
int who(int x){
	return (lower_bound(all(v),x)-v.begin())+1;
}
void init(){
	int BLOK=sqrt(n);cur=1;
	for(int i=1;i<=n;i++){
		bel[i]=cur;
		if(i%BLOK==0){
			if(i==n)
				en[cur]=i;
			else
				en[cur++]=i;
		}
	}en[cur]=n;
}
vector<int>adj[MAXN];
int arr[MAXN],ans[MAXN];
void upd(int p,int v){
	assert(1<=p and p<=n);
	assert(arr[p]==-1);
	arr[p]=v;
	adj[bel[p]].pb(v);
	sort(all(adj[bel[p]]));
}
int get(int p,int v){
	int ans=0;
	for(int i=p;i<=n;i++)
		ans+=(arr[i]>=v);
	return ans;
	for(int i=p;i<=en[bel[p]];i++)
		ans+=(arr[i]>=v);
	for(int i=bel[p]+1;i<=cur;i++)
		ans+=int(adj[i].size())-int(lower_bound(all(adj[i]),v)-adj[i].begin());
	return ans;
}
map<int,int>pm;
int main(){
	memset(arr,-1,sizeof arr);
   // freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
    	scanf("%d%d",a+i,b+i);
    	c[i]=a[i]+b[i];
    	id[i]=i;
    	while(pm[b[i]])
    		b[i]++;
    	pm[b[i]]=1;
		v.pb(b[i]);
    }
    sort(all(v));assert(int(v.size())==n);
    init();
    sort(id+1,id+n+1,cmp);
    for(int i=1;i<=q;i++){
    	scanf("%d%d%d",x+i,y+i,z+i),di[i]=i;
    	int yuf=0;
    	for(int j=1;j<=n;j++)
    		yuf+=(a[id[j]]>=x[i] && b[id[j]]>=y[i] && c[id[j]]>=z[i]);
    	printf("%d\n",yuf);
    }
    return 0;
    sort(di+1,di+q+1,cmp1);
    int p=1;
    vector<PII>tmp;
    for(int i=1;i<=q;i++){
    	while(p<=n and a[id[p]]>=x[di[i]]){
    		tmp.pb(mp(b[id[p]],c[id[p]]));
    		p++;
    		//upd(who(b[id[p]]),c[id[p]]),p++;
    	}
    	tr(it,tmp)
    		ans[di[i]]+=(it->ff>=y[di[i]] and it->ss>=z[di[i]]);
    	//ans[di[i]]=get(who(y[di[i]]),z[di[i]]);
    }
    for(int i=1;i<=q;i++)
    	printf("%d\n",ans[i]);
	return 0;
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:103:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  103 |     for(int i=1;i<=q;i++)
      |     ^~~
examination.cpp:105:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  105 |  return 0;
      |  ^~~~~~
examination.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
examination.cpp:71:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   71 |      scanf("%d%d",a+i,b+i);
      |      ~~~~~^~~~~~~~~~~~~~~~
examination.cpp:83:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   83 |      scanf("%d%d%d",x+i,y+i,z+i),di[i]=i;
      |      ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3052 KB Output is correct
2 Correct 3 ms 3052 KB Output is correct
3 Correct 3 ms 3052 KB Output is correct
4 Correct 2 ms 3052 KB Output is correct
5 Correct 2 ms 3052 KB Output is correct
6 Correct 2 ms 3052 KB Output is correct
7 Correct 31 ms 3488 KB Output is correct
8 Correct 31 ms 3436 KB Output is correct
9 Correct 42 ms 3428 KB Output is correct
10 Incorrect 210 ms 3408 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3027 ms 10160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3027 ms 10160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3052 KB Output is correct
2 Correct 3 ms 3052 KB Output is correct
3 Correct 3 ms 3052 KB Output is correct
4 Correct 2 ms 3052 KB Output is correct
5 Correct 2 ms 3052 KB Output is correct
6 Correct 2 ms 3052 KB Output is correct
7 Correct 31 ms 3488 KB Output is correct
8 Correct 31 ms 3436 KB Output is correct
9 Correct 42 ms 3428 KB Output is correct
10 Incorrect 210 ms 3408 KB Output isn't correct
11 Halted 0 ms 0 KB -