Submission #893197

#TimeUsernameProblemLanguageResultExecution timeMemory
893197AgentPengin버스 (JOI14_bus)C++14
100 / 100
155 ms39260 KiB
/** * author: AgentPengin ( Độc cô cầu bại ) * created: 23.12.2022 10:08:02 * too lazy to update time **/ #include<bits/stdc++.h> #define EL '\n' #define fi first #define se second #define NAME "TASK" #define ll long long #define lcm(a,b) (a/gcd(a,b))*b #define db(val) "["#val" = " << (val) << "] " #define bend(v) (v).begin(),(v).end() #define sz(v) (int)(v).size() #define ex exit(0) using namespace std; const ll mod = 1e9 + 7; const int inf = 0x1FFFFFFF; const int MAXN = 5e5 + 5; const int MAXM = 5e5 + 5; struct Info { int u,t,id,type; bool operator < (const Info &other) const { if (t != other.t) return t < other.t; else return type < other.type; } }; vector<Info> v; int n,m,mx[MAXN],d[MAXN]; vector<pair<int,int>> dd[MAXN]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if (ifstream(NAME".inp")) { freopen(NAME".inp","r",stdin); freopen(NAME".out","w",stdout); } cin >> n >> m; for (int i = 1;i <= m;i++) { int u,V,s,t; cin >> u >> V >> s >> t; v.push_back({u,s,i,1}); v.push_back({V,t,i,0}); } sort(bend(v)); for (int i = 1;i <= n;i++) mx[i] = -1; for (auto x : v) { if (x.type == 1) { if (x.u == 1) d[x.id] = x.t; else d[x.id] = mx[x.u]; } else { if (d[x.id] != -1) { dd[x.u].emplace_back(x.t,d[x.id]); mx[x.u] = max(mx[x.u],d[x.id]); } } } for (int i = 1;i < sz(dd[n]);i++) dd[n][i].se = max(dd[n][i].se,dd[n][i - 1].se); int q; cin >> q; while(q--) { int x; cin >> x; int k = upper_bound(bend(dd[n]),make_pair(x,inf)) - dd[n].begin() - 1; if (k == -1) cout << k << EL; else cout << dd[n][k].se << EL; } cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; } // agent pengin wants to take apio (with anya-san)

Compilation message (stderr)

bus.cpp: In function 'int main()':
bus.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bus.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...