Submission #1160236

#TimeUsernameProblemLanguageResultExecution timeMemory
1160236hainam2k9Bitaro’s Party (JOI18_bitaro)C++20
14 / 100
2095 ms6728 KiB
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,m,q,t,x,y,dist[MAXN],a[MAXN];
vector<int> adj[MAXN];
bool vis[MAXN];
int main()
{
    tt;
    if(fopen((NAME + ".INP").c_str(), "r")) fo;
    cin >> n >> m >> q;
    for(int i = 1; i<=m; ++i)
        cin >> x >> y, adj[x].pb(y);
    while(q--){
        memset(dist,-1,sizeof(dist));
        cin >> t >> y;
        for(int i = 1; i<=y; ++i)
            cin >> a[i], vis[a[i]]=1;
        for(int i = 1; i<=t; ++i){
            if(vis[i]&&dist[i]==-1) continue;
            dist[i]=max(dist[i],0);
            for(int j : adj[i])
                dist[j]=max(dist[j],dist[i]+1);
        }
        cout << dist[t] << "\n";
        for(int i = 1; i<=y; ++i)
            vis[a[i]]=0;
    }
}
//5 5 1
//1 2
//2 4
//4 5
//1 3
//3 5
//5 3
//1 2 4

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
bitaro.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:28:45: note: in expansion of macro 'fo'
   28 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...