답안 #925652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925652 2024-02-12T06:57:06 Z vjudge1 Joker (BOI20_joker) C++17
0 / 100
9 ms 24924 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast" 	
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

//#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 1e6 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const ld eps = 1e-6;

ll add (ll a, ll b) {
	a += b;
	if (a < 0) a += mod;
	if (a >= mod) a -= mod;
	return a;
}

ll mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

int n, m, Q;
vt<int> g[N];
int used[N];

struct Data {
	int x, y, id;
}edge[N];

string get (int l, int r) {
    for (int i = 1; i <= n; i++) used[i] = 0, g[i].clear();
	for (int i = 1; i <= m; i++) {
		int x = edge[i].x, y = edge[i].y, id = edge[i].id;
		if (!(id >= l && id <= r)) g[x].pb(y), g[y].pb(x);
	}
	bool ok = 1;
	queue<int> q;
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			q.push(i);
			used[i] = 1;
			while (!q.empty()) {
				int v = q.front();
				q.pop();
				for (auto to: g[v]) {
					if (!used[to]) {
						used[to] = 3 - used[v];
						q.push(to);
					}
					else if (used[to] == used[v]) ok = 0;
				}
			}
		}
	}
	return (!ok ? "YES" : "NO");
}

void solve () {
	cin >> n >> m >> Q;
	for (int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		edge[i] = {x, y, i};
	}
	while (Q--) {
		int l, r;
		cin >> l >> r;
		cout << get(l, r) << '\n';
	}
	cout << '\n';
}

bool testcases = 0;

signed main() {
#ifndef AMIR
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
	cin.tie(0) -> sync_with_stdio(0);
	int test = 1;
	if (testcases) cin >> test;
	for (int cs = 1; cs <= test; cs++) {
		solve();
	}
}

Compilation message

Joker.cpp: In function 'int main()':
Joker.cpp:93:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |  freopen(".in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~
Joker.cpp:94:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |  freopen(".out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 24924 KB Output isn't correct
2 Halted 0 ms 0 KB -