제출 #815180

#제출 시각아이디문제언어결과실행 시간메모리
815180waldiJail (JOI22_jail)C++17
0 / 100
5021 ms17660 KiB
#include<bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;

int main(){
	int q;
	scanf("%d", &q);
	while(q--){
		int n;
		scanf("%d", &n);
		vector<vector<int>> g(n+1);
		for(int i = n; --i;){
			int a, b;
			scanf("%d%d", &a, &b);
			g[a].emplace_back(b);
			g[b].emplace_back(a);
		}
		int m;
		scanf("%d", &m);
		vector<pii> trasy(m);
		vector<bool> czy(n+1, 0);
		REP(i, m) scanf("%d%d", &trasy[i].fi, &trasy[i].se), czy[trasy[i].fi] = 1;
		
		bool wyn = 1;
		REP(ile, m){
			bool ruch = 0;
			REP(i, m) if(czy[trasy[i].fi]){
				bool git = 0;
				function<void(int, int)> dfs = [&](int w, int o){
					if(czy[w] && w != trasy[i].fi) return;
					if(w == trasy[i].se) git = 1;
					for(int x : g[w]) if(x != o) dfs(x, w);
				};
				dfs(trasy[i].fi, 0);
				if(git){
					czy[trasy[i].fi] = 0;
					czy[trasy[i].se] = 1;
					ruch = 1;
					break;
				}
			}
			if(!ruch){wyn = 0; break;}
		}
		printf(wyn ? "Yes\n" : "No\n");
	}
}

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

jail.cpp: In function 'int main()':
jail.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &q);
      |  ~~~~~^~~~~~~~~~
jail.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
jail.cpp:18:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |    scanf("%d%d", &a, &b);
      |    ~~~~~^~~~~~~~~~~~~~~~
jail.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d", &m);
      |   ~~~~~^~~~~~~~~~
jail.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   REP(i, m) scanf("%d%d", &trasy[i].fi, &trasy[i].se), czy[trasy[i].fi] = 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...