제출 #1037348

#제출 시각아이디문제언어결과실행 시간메모리
103734812345678Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
191 ms53336 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; const int nx=4e5+5; int n, T, qs[nx], dsu[nx]; long long ans; map<int, int> mp; int find(int x) { if (dsu[x]==x) return x; return dsu[x]=find(dsu[x]); } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n=s.size(); for (int i=0; i<n; i++) mp[s[i]]=mp[t[i]]=0; for (auto &[x, y]:mp) y=++T; for (int i=1; i<=mp.size(); i++) dsu[i]=i; for (int i=0; i<n; i++) qs[mp[s[i]]]++, qs[mp[t[i]]]--, dsu[find(s[i])]=find(t[i]); for (int i=1; i<mp.size(); i++) { if (qs[i]>1) ans=1; if (qs[i]<1) dsu[find(i)]=find(i+1); } for (int i=1; i<=mp.size(); i++) if (find(1)!=find(i)) ans=1; return ans; }

컴파일 시 표준 에러 (stderr) 메시지

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i=1; i<=mp.size(); i++) dsu[i]=i;
      |                   ~^~~~~~~~~~~
railroad.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i=1; i<mp.size(); i++)
      |                   ~^~~~~~~~~~
railroad.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i=1; i<=mp.size(); i++) if (find(1)!=find(i)) ans=1;
      |                   ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...