# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
365397 |
2021-02-11T15:18:10 Z |
kostia244 |
popa (BOI18_popa) |
C++17 |
|
11 ms |
616 KB |
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#ifdef EVAL
#include"popa.h"
#endif
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
namespace local {
int ar[10010], qc = 0;
int query(int a, int b, int c, int d) {
qc++;
int x = 0, y = 0;
for(;a<=b;a++) x = __gcd(x, ar[a]);
for(;c<=d;c++) y = __gcd(y, ar[c]);
return x==y;
}
};
#ifndef EVAL
using namespace local;
#endif
int solve(int n, int *L, int *R) {
vector<int> st;
int rt = -1;
vector<int> start(n);
for(int i = 0; i < n; i++) L[i] = R[i] = -1;
for(int i = 0; i < n; i++) {
while(st.size() && !query(start[st.back()], i, st.back(), st.back())) st.pop_back();
if(st.empty()) {
if(rt != -1) L[i] = rt;
rt = i;
start[i] = 0;
} else {
R[st.back()] = i;
start[i] = i;
st.pop_back();
}
for(auto i : st) cout << i << " "; cout << endl;
st.push_back(i);
}
return rt;
}
#ifndef EVAL
int main() {
cin.tie(0)->sync_with_stdio(0);
//multitest([&](){});
int n;
cin >> n;
for(int i = 1; i <= n; i++) cin >> ar[i];
vector<int> L(n), R(n);
cout << solve(n, L.data(), R.data()) << endl;
for(int i = 0; i < n; i++) cout << L[i] << " " << R[i] << '\n';
cout << " :: " << qc << endl;
}
#endif
Compilation message
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:41:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
41 | for(auto i : st) cout << i << " "; cout << endl;
| ^~~
popa.cpp:41:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
41 | for(auto i : st) cout << i << " "; cout << endl;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
516 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
616 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |