| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 408960 | kwongweng | Bitaro’s Party (JOI18_bitaro) | C++17 | 1119 ms | 112896 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define F first
#define S second
ll MOD = 1000000007;
ll INF = 1000000000;
ll power(ll base, ll n){
if (n == 0) return 1;
if (n == 1) return base;
ll halfn = power(base, n/2);
if (n % 2 == 0) return (halfn * halfn) % MOD;
return (((halfn * halfn) % MOD) * base) % MOD;
}
ll inverse(ll n){
return power(n, MOD-2);
}
ll add(ll a, ll b){
return (a+b) % MOD;
}
ll mul(ll a, ll b){
return (a*b) % MOD;
}
ll gcd(ll a, ll b){
if (a == 0) return b;
if (a == 1) return 1;
return gcd(b%a, a);
}
int main(){
ios::sync_with_stdio(false);
int n, m, q; cin >> n >> m >> q;
vi g[n];
vii largest[n];
FOR(i, 0, m){
int s, e; cin >> s >> e;
g[e-1].pb(s-1);
}
FOR(i, 0, n){
vii all;
all.pb({0, i});
for (int u : g[i]){
for (ii node : largest[u]){
node.F++;
all.pb(node);
}
}
sort(all.begin(), all.end());
int len = all.size();
int pos = max(len-101, 0);
ROF(j, len-1, pos){
largest[i].pb(all[j]);
}
}
while (q--){
int t, y; cin >> t >> y;
t--;
if (y > 100){
vi dp(t+1);
FOR(i, 0, y){
int c; cin >> c; c--;
if (c > t) continue;
dp[c] = -1;
}
FOR(i, 0, t+1){
FOR(j, 0, g[i].size()){
int u = g[i][j];
if (dp[u] == -1) continue;
dp[i] = max(dp[i], dp[u]+1);
}
}
cout << dp[t] << '\n';
}
else{
set<int> st;
FOR(i, 0, y){
int c; cin >> c;
c--;
st.insert(c);
}
bool sol = true;
FOR(i, 0, largest[t].size()){
if (st.find(largest[t][i].S) == st.end()){
cout << largest[t][i].F << '\n';
sol = false; break;
}
}
if (sol) cout << -1 << '\n';
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
