Submission #203042

#TimeUsernameProblemLanguageResultExecution timeMemory
203042RakhmandBitaro’s Party (JOI18_bitaro)C++14
7 / 100
2089 ms320476 KiB
// // ROIGold.cpp // Main calisma // // Created by Rakhman on 05/02/2019. // Copyright © 2019 Rakhman. All rights reserved. // #include <cstring> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <queue> #include <cmath> #include <cstdlib> #include <ctime> #include <cassert> #include <iterator> #define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0); #define S second #define F first #define pb push_back #define nl '\n' #define NL cout << '\n'; #define EX exit(0) #define all(s) s.begin(), s.end() #define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k) const int MXN = 1e5 + 1; const long long MNN = 1e6 + 200; const long long MOD = 1e9 + 7; const long long INF = 1e18; const int OO = 1e9 + 500; typedef long long llong; typedef unsigned long long ullong; using namespace std; void istxt(bool yes){ if(yes == 1){ freopen("balancing.in", "r", stdin); //freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/e.txt", "w", stdout); }else{ freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin); } } int n, q, m, dp[MXN], lol[MXN], sq = 500; vector<int> g[MXN]; vector<pair<int, int> > best[MXN], ans[MXN]; bool visit[MXN]; int main () { ios; //istxt(0); cin >> n >> m >> q; for(int i = 1; i <= m; i++){ int u, v; cin >> u >> v; g[v].pb(u); } for(int i = 1; i <= n; i++){ for(int j = 0; j < g[i].size(); j++){ int last = g[i][j]; for(int e = 0; e < ans[last].size(); e++){ int cost = ans[last][e].F, pos = ans[last][e].S; lol[pos] = max(lol[pos], cost + 1); } } for(int j = 0; j < g[i].size(); j++){ int last = g[i][j]; for(int e = 0; e < ans[last].size(); e++){ int pos = ans[last][e].S; if(lol[pos] != -1){ ans[i].push_back({lol[pos], pos}); lol[pos] = -1; } } } ans[i].push_back({0, i}); sort(ans[i].begin(), ans[i].end(), greater<pair<int, int> >()); while(ans[i].size() > sq){ ans[i].pop_back(); } } while(q--){ int x, k; cin >> x >> k; vector<int> keks; for(int i = 0; i < k; i++){ int u; cin >> u; keks.push_back(u); visit[u] = 1; } if(k >= sq){ for(int i = x; i >= 1; i--){ dp[i] = -OO; } dp[x] = 0; int res = -1; for(int i = x; i >= 1; i--){ if(dp[i] < 0) continue; if(dp[i] > res && visit[i] == 0) res = dp[i]; for(int j = 0; j < g[i].size(); j++) dp[g[i][j]] = max(dp[g[i][j]], dp[i] + 1); } cout << res << nl; }else{ int res = -1; for(int i = 0; i < ans[x].size(); i++){ if(visit[ans[x][i].S] == 0){ res = ans[x][i].F; break; } } cout << res << nl; } for(int i = 0; i < keks.size(); i++){ visit[keks[i]] = 0; } } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:77:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < g[i].size(); j++){
                        ~~^~~~~~~~~~~~~
bitaro.cpp:79:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int e = 0; e < ans[last].size(); e++){
                            ~~^~~~~~~~~~~~~~~~~~
bitaro.cpp:84:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < g[i].size(); j++){
                        ~~^~~~~~~~~~~~~
bitaro.cpp:86:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int e = 0; e < ans[last].size(); e++){
                            ~~^~~~~~~~~~~~~~~~~~
bitaro.cpp:96:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(ans[i].size() > sq){
               ~~~~~~~~~~~~~~^~~~
bitaro.cpp:119:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j = 0; j < g[i].size(); j++) dp[g[i][j]] = max(dp[g[i][j]], dp[i] + 1);
                                ~~^~~~~~~~~~~~~
bitaro.cpp:124:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 0; i < ans[x].size(); i++){
                            ~~^~~~~~~~~~~~~~~
bitaro.cpp:132:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < keks.size(); i++){
                        ~~^~~~~~~~~~~~~
bitaro.cpp: In function 'void istxt(bool)':
bitaro.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("balancing.in", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...