Submission #18535

#TimeUsernameProblemLanguageResultExecution timeMemory
18535choyi0521버스 (JOI14_bus)C++98
Compilation error
0 ms0 KiB
#include<stdio.h> #include<vector> #include<algorithm> using namespace std; const int MAX_N = 1e5,MAX_M=3e5,MAX_Q=1e5; int n, m,q,cnt,res[MAX_Q]; vector<int> t[MAX_N+1],idx[MAX_N+1],adj[MAX_M*2]; pair<int, int> query[MAX_Q]; struct st { int a, b, x, y; }s[MAX_M]; bool ck[MAX_M * 2]; int maxi=-1; void dfs(int h) { if (h < idx[1].size()) maxi = max(maxi, t[1][h]); if (ck[h]) return; ck[h] = true; for (auto t : adj[h]) dfs(t); } int main() { scanf("%d %d", &n, &m); for (int i = 0; i < m; i++){ scanf("%d %d %d %d", &s[i].a, &s[i].b, &s[i].x, &s[i].y); t[s[i].a].push_back(s[i].x); t[s[i].b].push_back(s[i].y); } for (int i = 1; i <= n; i++) { sort(t[i].begin(), t[i].end()); t[i].erase(unique(t[i].begin(), t[i].end()),t[i].end()); for (int j = 0; j < t[i].size(); j++) { if (j) adj[cnt].push_back(cnt - 1); idx[i].push_back(cnt++); } } for (int i = 0; i < m; i++) { int a = lower_bound(t[s[i].a].begin(), t[s[i].a].end(), s[i].x) - t[s[i].a].begin(), b = lower_bound(t[s[i].b].begin(), t[s[i].b].end(), s[i].y) - t[s[i].b].begin(); adj[idx[s[i].b][b]].push_back(idx[s[i].a][a]); } scanf("%d", &q); for (int i = 0; i < q; i++) { scanf("%d",&query[i].first); query[i].second=i; } sort(query, query + q); for (int i = 0; i < q; i++) { int a = upper_bound(t[n].begin(), t[n].end(), query[i].first) - t[n].begin() - 1; if(a>=0) dfs(idx[n][a]); res[query[i].second] = maxi; } for (int i = 0; i < q; i++) printf("%d\n", res[i]); return 0; }

Compilation message (stderr)

bus.cpp: In function ‘void dfs(int)’:
bus.cpp:15:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (h < idx[1].size()) maxi = max(maxi, t[1][h]);
        ^
bus.cpp:18:7: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
  for (auto t : adj[h]) dfs(t);
       ^
bus.cpp:18:12: error: ‘t’ does not name a type
  for (auto t : adj[h]) dfs(t);
            ^
bus.cpp:19:1: error: expected ‘;’ before ‘}’ token
 }
 ^
bus.cpp:19:1: error: expected primary-expression before ‘}’ token
bus.cpp:19:1: error: expected ‘;’ before ‘}’ token
bus.cpp:19:1: error: expected primary-expression before ‘}’ token
bus.cpp:19:1: error: expected ‘)’ before ‘}’ token
bus.cpp:19:1: error: expected primary-expression before ‘}’ token
bus.cpp: In function ‘int main()’:
bus.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < t[i].size(); j++) {
                     ^
bus.cpp:21:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
                        ^
bus.cpp:23:59: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &s[i].a, &s[i].b, &s[i].x, &s[i].y);
                                                           ^
bus.cpp:40:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
                 ^
bus.cpp:42:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&query[i].first);
                              ^