Submission #1284282

#TimeUsernameProblemLanguageResultExecution timeMemory
1284282muhammad-mutahirThe Ties That Guide Us (CEOI23_incursion)C++20
Compilation error
0 ms0 KiB
#include <vector> #include "incursion.h" #include <cstdio> using namespace std; #include <bits/stdc++.h> vector<int> mark(vector<pair<int, int>> F, int safe) { int N = F.size()+1; vector<int>deg(N+1,0); vector<vector<int>>adj(N+1); for(auto i:F){ adj[i.first].push_back(i.second); adj[i.second].push_back(i.first); deg[i.first]++; deg[i.second]++; } queue<int>Q; Q.push(safe); vector<int>vis(N+1,0); vis[safe] = 2; int c = 2; while(Q.size()){ int x = Q.front(); Q.pop(); for(int i:adj[x]){ if(!vis[i]){ Q.push(i); vis[i] = c; } } c--; c+=3; c%=3; } // print(vis); return vis; } void locate(vector<pair<int, int>> F, int curr, int t) { int N = F.size()+1; vector<int>deg(N+1,0); vector<vector<int>>adj(N+1); for(auto i:F){ adj[i.first].push_back(i.second); adj[i.second].push_back(i.first); deg[i.first]++; deg[i.second]++; } queue<int>Q; vector<int>viss(N+1,0); int c1 = visit(adj[curr][0]); int c = visit(curr); int c2 = visit(adj[curr][2]); int p = visit(curr); int cr if(c1 == 0 and c == 1 and c2 == 2){ Q.push(c2); cr = visit(c2); viss[c] = 1; viss[c2] = 1; } else if(c1 == 1 and c == 2 and c2 == 0){ cr = visit(c2); Q.push(c2); viss[c] = 1; viss[c2] = 1; } else if(c1 == 2 and c == 0 and c2 == 1){ cr = visit(c2); Q.push(c2); viss[c] = 1; viss[c2] = 1; } else if(c1 == 2 and c == 1 and c2 == 0){ cr = visit(c1); Q.push(c1); viss[c] = 1; viss[c1] = 1; } else if(c1 == 1 and c == 0 and c2 == 2){ cr = visit(c1); Q.push(c1); viss[c] = 1; viss[c1] = 1; } else if(c1 == 0 and c == 2 and c2 == 1){ cr = visit(c1); Q.push(c1); viss[c] = 1; viss[c1] = 1; } int nt; while(Q.size()){ int x = Q.front(); Q.pop(); for(int i:adj[x]){ if(!viss[i]){ Q.push(i); viss[i] = 1; nt = visit(i); if(nt == 2 and cr == 2 and pv == 2){ int res = visit(x); return; } pv = cr; cr = nt; } } } } // int main(){ // vector<pair<int,int>>qur = {{1,2},{2,3},{3,4}}; // vector<int>ans = mark(qur,3); // for(auto i:ans){ // cout<<i<<" "; // } // cout<<endl; // }

Compilation message (stderr)

incursion.cpp: In function 'void locate(std::vector<std::pair<int, int> >, int, int)':
incursion.cpp:59:3: error: expected initializer before 'if'
   59 |   if(c1 == 0 and c == 1 and c2 == 2){
      |   ^~
incursion.cpp:65:3: error: 'else' without a previous 'if'
   65 |   else if(c1 == 1 and c == 2 and c2 == 0){
      |   ^~~~
incursion.cpp:66:9: error: 'cr' was not declared in this scope; did you mean 'c2'?
   66 |         cr = visit(c2);
      |         ^~
      |         c2
incursion.cpp:72:9: error: 'cr' was not declared in this scope; did you mean 'c2'?
   72 |         cr = visit(c2);
      |         ^~
      |         c2
incursion.cpp:79:9: error: 'cr' was not declared in this scope; did you mean 'c2'?
   79 |         cr = visit(c1);
      |         ^~
      |         c2
incursion.cpp:85:9: error: 'cr' was not declared in this scope; did you mean 'c2'?
   85 |         cr = visit(c1);
      |         ^~
      |         c2
incursion.cpp:91:9: error: 'cr' was not declared in this scope; did you mean 'c2'?
   91 |         cr = visit(c1);
      |         ^~
      |         c2
incursion.cpp:105:40: error: 'cr' was not declared in this scope; did you mean 'c2'?
  105 |                         if(nt == 2 and cr == 2 and pv == 2){
      |                                        ^~
      |                                        c2
incursion.cpp:105:52: error: 'pv' was not declared in this scope; did you mean 'p'?
  105 |                         if(nt == 2 and cr == 2 and pv == 2){
      |                                                    ^~
      |                                                    p
incursion.cpp:109:25: error: 'pv' was not declared in this scope; did you mean 'p'?
  109 |                         pv = cr;
      |                         ^~
      |                         p
incursion.cpp:109:30: error: 'cr' was not declared in this scope; did you mean 'c2'?
  109 |                         pv = cr;
      |                              ^~
      |                              c2