제출 #603389

#제출 시각아이디문제언어결과실행 시간메모리
603389ShithilaSplit the Attractions (IOI19_split)C++14
0 / 100
1 ms212 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> res; int m=p.size(); //cout<<m<<endl; int connected[m][2]; bool visited[m]; for(int i=0;i<n;i++) { connected[i][0]=-1; connected[i][1]=-1; visited[i]=false; res.push_back(3); } for(int i=0;i<m;i++) { int x=p[i]; int y=q[i]; if(connected[x][0]==-1) connected[x][0]=y; else connected[x][1]=y; if(connected[y][0]==-1) connected[y][0]=x; else connected[y][1]=x; } int startpos=-1; int endpos=-1; for(int i=0;i<n;i++) { if(connected[i][0]==-1 || connected[i][1]==-1) { if(startpos==-1) startpos=i; else endpos=i; } } if(startpos==-1) { bool error=false; startpos=0; int startcount=0; while(startcount<a) { visited[startpos]=true; res[startpos]=1; startcount++; if(connected[startpos][0]=-1) { error=true; break; } if(visited[connected[startpos][0]]==true) { if(connected[startpos][1]=-1) { error=true; break; } startpos=connected[startpos][1]; } else startpos=connected[startpos][0]; } int endcount=0; endpos=startpos; while(endcount<b) { visited[endpos]=true; res[endpos]=2; endcount++; if(connected[endpos][0]=-1) { error=true; break; } if(visited[connected[endpos][0]]==true) { if(connected[endpos][0]=-1) { error=true; break; } endpos=connected[endpos][1]; } else endpos=connected[endpos][0]; } if(error==true) { for(int i=0;i<n;i++) { res[i]=0; } } return res; } bool error=false; int startcount=0; while(startcount<a) { visited[startpos]=true; res[startpos]=1; startcount++; if(connected[startpos][0]=-1) { error=true; break; } if(visited[connected[startpos][0]]==true) { if(connected[startpos][1]=-1) { error=true; break; } startpos=connected[startpos][1]; } else startpos=connected[startpos][0]; } int endcount=0; while(endcount<b) { visited[endpos]=true; res[endpos]=2; endcount++; if(connected[endpos][0]=-1) { error=true; break; } if(visited[connected[endpos][0]]==true) { if(connected[endpos][1]=-1) { error=true; break; } endpos=connected[endpos][1]; } else endpos=connected[endpos][0]; } if(error==true) { for(int i=0;i<n;i++) { res[i]=0; } } return res; }

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:48:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   48 |    if(connected[startpos][0]=-1)
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:55:30: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   55 |     if(connected[startpos][1]=-1)
      |        ~~~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:71:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   71 |    if(connected[endpos][0]=-1)
      |       ~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:78:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   78 |     if(connected[endpos][0]=-1)
      |        ~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:104:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  104 |   if(connected[startpos][0]=-1)
      |      ~~~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:111:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  111 |    if(connected[startpos][1]=-1)
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:126:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  126 |   if(connected[endpos][0]=-1)
      |      ~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:133:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  133 |    if(connected[endpos][1]=-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...
#Verdict Execution timeMemoryGrader output
Fetching results...