답안 #125507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125507 2019-07-05T14:11:24 Z hugo_pm Bitaro’s Party (JOI18_bitaro) C++17
0 / 100
6 ms 4988 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = (int)(1e5) + 5;
const int lowCte = 350;
const int highCte = 360;

vector<int> revAdj[borne];
vector<pii> meil[borne];

int nbVilles, nbCan, nbReq;

int sk[borne];
int tps = 0;

int dp[borne];

void solve()
{
	cin >> nbVilles >> nbCan >> nbReq;
	form(i, nbCan) {
		int u, v; cin >> u >> v; --u; --v;
		revAdj[v].push_back(u);
	}

	form(i, nbVilles) {
		meil[i].push_back({0, i});
		for (int vo : revAdj[i]) {
			for (auto tr : meil[vo]) {
				meil[i].push_back({tr.fi+1, tr.se});
			}
		}
		sort(meil[i].begin(), meil[i].end());
		reverse(meil[i].begin(), meil[i].end());
		int da = max(0LL, (int)(meil[i].size()) - highCte);
		form(i, da) meil[i].pop_back();
	}

	form(i, nbReq) {
		int villeArr; cin >> villeArr; --villeArr;
		++tps;
		int nbSkips; cin >> nbSkips;
		form(iRcp, nbSkips) { int x; cin >> x; --x; sk[x] = tps; }
		if (nbSkips < lowCte) {
			for (auto tr : meil[villeArr]) {
				if (sk[tr.se] != tps) {
					cout << tr.fi << "\n";
					break;
				}
			}
		} else {
			form(pos, villeArr+1) {
				dp[pos] = 0;
				for (int vo : revAdj[pos]) if (dp[vo] > 0 || sk[vo] != tps) chmax(dp[pos], dp[vo]+1);
			}
			cout << dp[villeArr] << "\n";
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Incorrect 6 ms 4988 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Incorrect 6 ms 4988 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4984 KB Output is correct
2 Incorrect 6 ms 4988 KB Output isn't correct
3 Halted 0 ms 0 KB -