답안 #587609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587609 2022-07-02T06:43:17 Z cfalas Event Hopping (BOI22_events) C++17
10 / 100
1500 ms 41336 KB
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)

int t, n;
vi a, b;
vector<vi> adj;
int ans[5500][5500];
int main(){
	int q;
	cin>>n>>q;
	adj.assign(n+1, vi());
	vii e(n);
	FOR(i,n){
		cin>>e[i].F>>e[i].S;
	}
	FOR(i,n){
		FOR(j,n){
			if(i==j) continue;
			if(e[j].F<=e[i].S && e[i].S<=e[j].S){
				adj[i+1].push_back(j+1);
			}
		}
		/*
		cout<<i+1<<": ";
		FOA(v, adj[i+1]) cout<<v<<" ";
		cout<<endl;
		*/
	}
	FORi(i,1,n+1){
		priority_queue<ii> q;
		q.push({0, i});
		FOR(j,n+1) ans[i][j] = MOD;
		ans[i][i] = 0;
		while(!q.empty()){
			ii t = q.top();
			q.pop();

			if(-t.F > ans[i][t.S]) continue;

			FOA(v, adj[t.S]){
				if(ans[i][v] > 1 - t.F){
					ans[i][v] = 1 - t.F;
					q.push({-ans[i][v], v});
				}
			}

		}
	}
	while(q--){
		int a, b;
		cin>>a>>b;
		if(ans[a][b] < MOD) cout<<ans[a][b]<<endl;
		else cout<<"impossible\n";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1529 ms 4528 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 22 ms 8276 KB Output is correct
4 Correct 14 ms 8276 KB Output is correct
5 Correct 21 ms 8224 KB Output is correct
6 Correct 68 ms 9132 KB Output is correct
7 Correct 159 ms 9828 KB Output is correct
8 Correct 191 ms 10868 KB Output is correct
9 Correct 871 ms 12316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 22 ms 8276 KB Output is correct
4 Correct 14 ms 8276 KB Output is correct
5 Correct 21 ms 8224 KB Output is correct
6 Correct 68 ms 9132 KB Output is correct
7 Correct 159 ms 9828 KB Output is correct
8 Correct 191 ms 10868 KB Output is correct
9 Correct 871 ms 12316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 22 ms 8292 KB Output is correct
13 Correct 14 ms 8296 KB Output is correct
14 Correct 22 ms 8208 KB Output is correct
15 Correct 63 ms 9076 KB Output is correct
16 Correct 181 ms 9836 KB Output is correct
17 Correct 187 ms 10924 KB Output is correct
18 Correct 891 ms 12288 KB Output is correct
19 Execution timed out 1578 ms 41336 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 22 ms 8276 KB Output is correct
4 Correct 14 ms 8276 KB Output is correct
5 Correct 21 ms 8224 KB Output is correct
6 Correct 68 ms 9132 KB Output is correct
7 Correct 159 ms 9828 KB Output is correct
8 Correct 191 ms 10868 KB Output is correct
9 Correct 871 ms 12316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 22 ms 8288 KB Output is correct
13 Correct 15 ms 8312 KB Output is correct
14 Correct 23 ms 8272 KB Output is correct
15 Correct 70 ms 9200 KB Output is correct
16 Correct 154 ms 9860 KB Output is correct
17 Correct 175 ms 10964 KB Output is correct
18 Correct 874 ms 12312 KB Output is correct
19 Execution timed out 1556 ms 6024 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1514 ms 4468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 1529 ms 4528 KB Time limit exceeded
3 Halted 0 ms 0 KB -