제출 #109691

#제출 시각아이디문제언어결과실행 시간메모리
109691njchung99Matryoshka (JOI16_matryoshka)C++14
26 / 100
3 ms384 KiB
#include<cstdio> #include<cstring> #include<vector> #include<algorithm> using namespace std; vector<vector<int>> vt; int dap = 0; int q, w; pair<int, int> a[2010]; int visited[2010]; int indegree[2010]; void dfs(int here) { visited[here] = 1; int update = 0; for (int i = 0; i < vt[here].size(); i++) { int next = vt[here][i]; if (a[next].first >= q && a[next].second <= w&&!visited[next]&&indegree[next]==1) { update = 1; dfs(next); break; } } if (!update) { for (int i = 0; i < vt[here].size(); i++) { int next = vt[here][i]; if (a[next].first >= q && a[next].second <= w && !visited[next]) { dfs(next); break; } } } for (int i = 0; i < vt[here].size(); i++) { int next = vt[here][i]; if (a[next].first >= q && a[next].second <= w && !visited[next]) { indegree[next]--; } } } int main() { int n,m; scanf("%d %d", &n,&m); vt.resize(n + 1); for (int i = 0; i < n; i++) { scanf("%d %d", &a[i].first, &a[i].second); } sort(a, a + n); reverse(a, a + n); for (int i = 0; i < n; i++) { for (int y = 0; y < n; y++) { if (a[i].first > a[y].first&&a[i].second > a[y].second) { vt[i].push_back(y); indegree[y]++; } } } while(m--){ scanf("%d %d", &q, &w); memset(visited, 0, sizeof(visited)); int oo = 0; for (int i = 0; i < n; i++) { if (a[i].first >= q && a[i].second <= w&&!visited[i]) { dfs(i); oo++; } } printf("%d\n", oo); } }

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

matryoshka.cpp: In function 'void dfs(int)':
matryoshka.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < vt[here].size(); i++) {
                  ~~^~~~~~~~~~~~~~~~~
matryoshka.cpp:24:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < vt[here].size(); i++) {
                   ~~^~~~~~~~~~~~~~~~~
matryoshka.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < vt[here].size(); i++) {
                  ~~^~~~~~~~~~~~~~~~~
matryoshka.cpp: In function 'int main()':
matryoshka.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n,&m);
  ~~~~~^~~~~~~~~~~~~~~~
matryoshka.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a[i].first, &a[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &q, &w);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...