Submission #280345

#TimeUsernameProblemLanguageResultExecution timeMemory
280345spdskatrJoker (BOI20_joker)C++14
14 / 100
83 ms632 KiB
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #define fi first #define se second using namespace std; typedef pair<int, int> pii; int N, M, Q, seen[2005], col[2005]; vector<pii> graph[2005]; int dfs(int x, int l, int r) { seen[x] = 1; for (pii p : graph[x]) { int v = p.fi, e = p.se; if (e < l || e > r) { if (seen[v]) { if (col[v] == col[x]) return 1; } else { col[v] = !col[x]; if (dfs(v, l, r)) return 1; } } } return 0; } int main() { scanf("%d %d %d", &N, &M, &Q); for (int i = 1; i <= M; i++) { int a, b; scanf("%d %d", &a, &b); graph[a].push_back({ b, i }); graph[b].push_back({ a, i }); } for (int q = 0; q < Q; q++) { int l, r; scanf("%d %d", &l, &r); memset(seen, 0, sizeof(seen)); memset(col, 0, sizeof(col)); int nice = 0; for (int i = 1; i <= N; i++) { if (!seen[i]) if (dfs(i, l, r)) { nice = 1; break; } } if (nice) printf("YES\n"); else printf("NO\n"); } }

Compilation message (stderr)

Joker.cpp: In function 'int main()':
Joker.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |  scanf("%d %d %d", &N, &M, &Q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Joker.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   35 |   scanf("%d %d", &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~
Joker.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |   scanf("%d %d", &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...