Submission #282750

#TimeUsernameProblemLanguageResultExecution timeMemory
282750peti1234Werewolf (IOI18_werewolf)C++17
15 / 100
332 ms19704 KiB
#include <bits/stdc++.h> using namespace std; using vi=vector<int>; #define rep(n) for (int i=0; i<n; i++) const int c=3002; int m, q; vi sz[c], sol; bool kis[c], nagy[c], jo; void kdfs(int a, int b) { kis[a]=1; rep(sz[a].size()) { int x=sz[a][i]; if (!kis[x] && x<=b) kdfs(x, b); } } void ndfs(int a, int b) { nagy[a]=1; rep(sz[a].size()) { int x=sz[a][i]; if (!nagy[x] && x>=b) ndfs(x, b); } } vi check_validity(int n, vi x, vi y, vi s, vi e, vi l, vi r) { m=x.size(), q=s.size(); rep(m) { sz[x[i]].push_back(y[i]), sz[y[i]].push_back(x[i]); } rep(q) { jo=0; rep(n) kis[i]=0, nagy[i]=0; kdfs(e[i], r[i]); ndfs(s[i], l[i]); rep(n) if (kis[i] && nagy[i]) jo=1; sol.push_back(jo); } return sol; } /* int b1, b2, b3; vi v1, v2, v3, v4, v5, v6, v7; int main() { cin >> b1 >> b2 >> b3; rep(b2) { int a; cin >> a; v1.push_back(a); } rep(b2) { int a; cin >> a; v2.push_back(a); } rep(b3) { int a; cin >> a; v3.push_back(a); } rep(b3) { int a; cin >> a; v4.push_back(a); } rep(b3) { int a; cin >> a; v5.push_back(a); } rep(b3) { int a; cin >> a; v6.push_back(a); } v7=check_validity(b1, v1, v2, v3, v4, v5, v6); rep(b3) cout << v7[i] << " "; return 0; } */ /* 6 6 3 5 1 1 3 3 5 1 2 3 4 0 2 4 4 5 2 2 4 1 2 3 2 2 4 */

Compilation message (stderr)

werewolf.cpp: In function 'void kdfs(int, int)':
werewolf.cpp:5:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(n) for (int i=0; i<n; i++)
      |                              ~^~~~~~~~
    6 | const int c=3002;
      | ~~~~~~~~~~~~~~~~~              
    7 | int m, q;
      | ~~~~~~~~~                      
    8 | vi sz[c], sol;
      | ~~~~~~~~~~~~~~                 
    9 | bool kis[c], nagy[c], jo;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~      
   10 | void kdfs(int a, int b) {
      | ~~~~~~~~~~~~~~~~~~~~~~~~~      
   11 |     kis[a]=1;
      |     ~~~~~~~~~                  
   12 |     rep(sz[a].size()) {
      |     ~~~~~~~~~~~~~~~~           
werewolf.cpp:12:5: note: in expansion of macro 'rep'
   12 |     rep(sz[a].size()) {
      |     ^~~
werewolf.cpp: In function 'void ndfs(int, int)':
werewolf.cpp:5:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(n) for (int i=0; i<n; i++)
      |                              ~^~~~~~~~
    6 | const int c=3002;
      | ~~~~~~~~~~~~~~~~~              
    7 | int m, q;
      | ~~~~~~~~~                      
    8 | vi sz[c], sol;
      | ~~~~~~~~~~~~~~                 
    9 | bool kis[c], nagy[c], jo;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~      
   10 | void kdfs(int a, int b) {
      | ~~~~~~~~~~~~~~~~~~~~~~~~~      
   11 |     kis[a]=1;
      |     ~~~~~~~~~                  
   12 |     rep(sz[a].size()) {
      |     ~~~~~~~~~~~~~~~~~~~        
   13 |         int x=sz[a][i];
      |         ~~~~~~~~~~~~~~~        
   14 |         if (!kis[x] && x<=b) kdfs(x, b);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   15 |     }
      |     ~                          
   16 | }
      | ~                              
   17 | void ndfs(int a, int b) {
      | ~~~~~~~~~~~~~~~~~~~~~~~~~      
   18 |     nagy[a]=1;
      |     ~~~~~~~~~~                 
   19 |     rep(sz[a].size()) {
      |     ~~~~~~~~~~~~~~~~           
werewolf.cpp:19:5: note: in expansion of macro 'rep'
   19 |     rep(sz[a].size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...