Submission #628791

#TimeUsernameProblemLanguageResultExecution timeMemory
628791IwanttobreakfreeTug of War (BOI15_tug)C++17
0 / 100
107 ms262144 KiB
#include <iostream> #include <vector> using namespace std; bool bt(int i,vector<pair<int,int>> pos,int l,int r,int k,vector<int>& posl,vector<int>& posr,vector<int>& s){ if(i==pos.size()&&abs(l-r)<=k)return true; if(posl[pos[i].first]){ posl[pos[i].first]=0; l+=s[i]; if(bt(i+1,pos,l,r,k,posl,posr,s))return true; posl[pos[i].first]=1; l-=s[i]; } if(posr[pos[i].second]){ posr[pos[i].second]=0; r+=s[i]; if(bt(i+1,pos,l,r,k,posl,posr,s))return true; posr[pos[i].second]=1; r-=s[i]; } return false; } int main(){ int n,k; cin>>n>>k; vector<pair<int,int>> pos(2*n); vector<int> posl(n,1),posr(n,1),s(2*n); for(int i=0;i<2*n;i++)cin>>pos[i].first>>pos[i].second>>s[i]; for(int i=0;i<2*n;i++){ pos[i].first--;pos[i].second--; } if(bt(0,pos,0,0,k,posl,posr,s))cout<<"YES\n"; else cout<<"NO\n"; }

Compilation message (stderr)

tug.cpp: In function 'bool bt(int, std::vector<std::pair<int, int> >, int, int, int, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
tug.cpp:5:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     if(i==pos.size()&&abs(l-r)<=k)return true;
      |        ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...