# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
555259 |
2022-04-30T10:40:59 Z |
computerbox |
Radio (COCI22_radio) |
C++14 |
|
1500 ms |
173808 KB |
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 400010
using namespace std;
struct segment
{
vector<pair<int, int> >primes;
};
segment t[4 * 1000010];
int used[1000010];
segment mergee(segment &one, segment &two)
{
segment three;
int l = 0;
int r = 0;
while(l < (int)one.primes.size() && r < (int)two.primes.size())
{
if(one.primes[l].first < two.primes[r].first)
{
three.primes.pb(one.primes[l]);
l++;
}
else if(one.primes[l].first == two.primes[r].first)
{
three.primes.pb({one.primes[l].first, one.primes[l].second + two.primes[r].second});
l++;
r++;
}
else
{
three.primes.pb(two.primes[r]);
r++;
}
}
while(l < (int)one.primes.size())
{
three.primes.pb(one.primes[l]);
l++;
}
while(r < (int)two.primes.size())
{
three.primes.pb(two.primes[r]);
r++;
}
return three;
}
vector<int>primes;
vector<pair<int, int> >primes1[1000010];
void update(int v, int l, int r, int pos)
{
if(l == r)
{
if(!t[v].primes.empty())
{
t[v].primes.clear();
return ;
}
for(auto i: primes1[l])
{
t[v].primes.pb(i);
}
return ;
}
int mid = l + (r - l) / 2;
if(pos <= mid)update(v * 2, l, mid, pos);
else update(v * 2 + 1, mid + 1, r, pos);
t[v] = mergee(t[v * 2], t[v * 2 + 1]);
}
segment query(int v, int l, int r, int nac, int konec)
{
if(l > konec || r < nac)
{
segment x;
return x;
}
if(l >= nac && r <= konec)return t[v];
int mid = l + (r - l)/ 2;
segment one = query(v * 2, l ,mid, nac, konec);
segment two = query(v * 2 + 1, mid + 1, r, nac, konec);
return mergee(one, two);
}
int main(){
FAST_READ;
cin.tie(0);
cout.tie(0);
for(int i = 2; i <= 1000000; i++)
{
if(used[i])continue;
primes1[i].pb({i, 1});
for(long long j = i * 2; j <= 1000000; j += i)
{
used[j] = 1;
primes1[j].pb({i, 1});
}
}
int n, q;
cin >> n >> q;
while(q--)
{
char c;
cin >> c;
if(c == 'S')
{
int x;
cin >> x;
update(1, 1, n, x);
}
else
{
int x, y;
cin >> x >> y;
segment res = query(1, 1, n, x, y);
int sig = 0;
for(auto i: res.primes)
{
if(i.second > 1){ sig = 1; break;}
}
if(!sig)cout << "NE" << endl;
else cout << "DA" << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
510 ms |
168260 KB |
Output is correct |
2 |
Correct |
520 ms |
168360 KB |
Output is correct |
3 |
Correct |
496 ms |
168268 KB |
Output is correct |
4 |
Correct |
493 ms |
168432 KB |
Output is correct |
5 |
Correct |
507 ms |
168264 KB |
Output is correct |
6 |
Correct |
503 ms |
168208 KB |
Output is correct |
7 |
Correct |
506 ms |
168300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1590 ms |
173808 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
510 ms |
168260 KB |
Output is correct |
2 |
Correct |
520 ms |
168360 KB |
Output is correct |
3 |
Correct |
496 ms |
168268 KB |
Output is correct |
4 |
Correct |
493 ms |
168432 KB |
Output is correct |
5 |
Correct |
507 ms |
168264 KB |
Output is correct |
6 |
Correct |
503 ms |
168208 KB |
Output is correct |
7 |
Correct |
506 ms |
168300 KB |
Output is correct |
8 |
Execution timed out |
1590 ms |
173808 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |