답안 #929423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
929423 2024-02-18T05:31:30 Z tamir1 섬 항해 (CEOI13_adriatic) C++14
25 / 100
2000 ms 262144 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
ll n,x,y,i,j,a,b,c,d,ans[250005],vis[250005];
pair<ll,ll> p[250005];
vector<ll> v[250005];
queue<pair<ll,ll>> q;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		p[i]={x,y};
	}
	for(i=1;i<=n;i++){
		a=p[i].ff;
		b=p[i].ss;
		for(j=i+1;j<=n;j++){
			c=p[j].ff;
			d=p[j].ss;
			if((a>c && b>d) || (a<c && b<d)){
				v[i].push_back(j);
				v[j].push_back(i);
			}
		}
	}
	for(i=1;i<=n;i++){
		vis[i]=i;
		q.push({i,0});
		while(!q.empty()){
			a=q.front().ff;
			b=q.front().ss;
			q.pop();
			ans[i]+=b;
			for(j=0;j<v[a].size();j++){
				c=v[a][j];
				if(vis[c]<i){
					vis[c]=i;
					q.push({c,b+1});
				}
			}
		}
	}
	for(i=1;i<=n;i++) {
		printf("%lld\n",ans[i]);
	}
}

Compilation message

adriatic.cpp: In function 'int main()':
adriatic.cpp:11:10: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   11 |  scanf("%d",&n);
      |         ~^  ~~
      |          |  |
      |          |  long long int*
      |          int*
      |         %lld
adriatic.cpp:13:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   13 |   scanf("%d%d",&x,&y);
      |          ~^    ~~
      |           |    |
      |           int* long long int*
      |          %lld
adriatic.cpp:13:13: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   13 |   scanf("%d%d",&x,&y);
      |            ~^     ~~
      |             |     |
      |             int*  long long int*
      |            %lld
adriatic.cpp:36:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for(j=0;j<v[a].size();j++){
      |            ~^~~~~~~~~~~~
adriatic.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
adriatic.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d%d",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 2 ms 10840 KB Output is correct
4 Correct 3 ms 10840 KB Output is correct
5 Correct 2 ms 10844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 470 ms 12240 KB Output is correct
2 Execution timed out 2057 ms 24156 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2031 ms 20168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1050 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 843 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -