CSES - Leirikisa 3 - Results
Submission details
Task:Joker
Sender:a256
Submission time:2023-04-19 17:48:54 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'bool reitti(ll, ll)':
input/code.cpp:10:24: error: 'i' was not declared in this scope
   10 |         if(z[s]==ii&&p&i) return true;
      |                        ^
input/code.cpp: In function 'int main()':
input/code.cpp:33:12: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'll' {aka '__int128'})
   33 |         cin>>N>>M>>Q;
      |         ~~~^~~
      |         |    |
      |         |    ll {aka __int128}
      |         std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from input/code.cpp:1:
/usr/include/c++/11/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::...

Code

#include <bits/stdc++.h>
using namespace std;
using ll=__int128_t;

ll N,M,Q,a,b,l,r,z[222222];
ll ii;
map<ll,map<ll,pair<ll,ll>>> v;

bool reitti(ll s,ll p){
	if(z[s]==ii&&p&i) return true;
	z[s]=ii;
	for(auto &u:v[s]){
		ll us=u.first;
		ll idx=u.second.first;
		if(l<=idx&&idx<=r) continue;
		if(u.second.second==ii) continue;
		v[s][us].second=ii;
		v[us][s].second=ii;
		if(reitti(us,p+1)) return true;
	}
	return false;
}

bool on_reitti(){
	for(ll i=1;i<=N;++i,++ii){
		if(reitti(i,0)) return true;
	}
	return false;
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin>>N>>M>>Q;
	for(ll i=1;i<=M;++i){
		cin>>a>>b;
		v[a][b]={i,0};
		v[b][a]={i,0};
	}

	for(ll i=0;i<Q;++i){
		cin>>l>>r;
		if(on_reitti()) cout<<"YES\n";
		else cout<<"NO\n";
	}
}