제출 #800132

#제출 시각아이디문제언어결과실행 시간메모리
800132becaido식물 비교 (IOI20_plants)C++17
5 / 100
123 ms29824 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> using namespace std; #ifndef WAIMAI #include "plants.h" #endif #ifdef WAIMAI #define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE) void dout() {cout << '\n';} template<typename T, typename...U> void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);} #else #define debug(...) 7122 #endif #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second const int SIZE = 2e5 + 5; int n, k; int a[SIZE]; vector<int> adj[SIZE]; vector<pair<int, int>> g[SIZE]; void init(int _k, vector<int> r) { n = r.size(); k = _k; FOR (i, 0, n - 1) a[i] = r[i]; if (k == 2) { FOR (i, 0, n - 1) { if (a[i] == 1) adj[i].pb((i + 1) % n); else adj[(i + 1) % n].pb(i); } int sz = 0; FOR (i, 0, n - 1) if (adj[i].size() == 2) { for (int x : adj[i]) { int cnt = 0; g[i].pb(sz, cnt++); while (adj[x].size()) { g[x].pb(sz, cnt++); x = adj[x][0]; } g[x].pb(sz, cnt++); sz++; } } } } int compare_plants(int x, int y) { if (k == 2) { for (auto [gx, px] : g[x]) for (auto [gy, py] : g[y]) if (gx == gy) { return px < py ? -1 : 1; } return 0; } } /* in1 4 3 2 0 1 1 2 0 2 1 2 out1 1 -1 in2 4 2 2 0 1 0 1 0 3 1 3 out2 1 0 */ #ifdef WAIMAI int main() { int n, k, q; vector<int> r; vector<int> x; vector<int> y; vector<int> answer; assert(scanf("%d%d%d", &n, &k, &q) == 3); r.resize(n); answer.resize(q); for (int i = 0; i < n; i++) { int value; assert(scanf("%d", &value) == 1); r[i] = value; } x.resize(q); y.resize(q); for (int i = 0; i < q; i++) { assert(scanf("%d%d", &x[i], &y[i]) == 2); } fclose(stdin); init(k, r); for (int i = 0; i < q; i++) { answer[i] = compare_plants(x[i], y[i]); } for (int i = 0; i < q; i++) { printf("%d\n", answer[i]); } fclose(stdout); return 0; } #endif

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

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
#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...