# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
555242 |
2022-04-30T10:08:58 Z |
computerbox |
Radio (COCI22_radio) |
C++14 |
|
1500 ms |
238468 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 create(int el)
{
int tmp = el;
int ind = 0;
for(int i = 2; i * i <= el; i++)
{
int cnt = 0;
while(el % i == 0)
{
cnt++;
el /= i;
}
if(cnt)primes1[tmp].pb({i, 1});
ind++;
}
if(el > 1)
{
primes1[tmp].pb({el, 1});
}
}
void update(int v, int l, int r, int pos)
{
if(l == r)
{
if(!t[v].primes.empty())
{
t[v].primes.clear();
return ;
}
create(l);
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;
for(long long j = i * 1LL * i; j <= 1000000; j += i)
{
used[j] = 1;
}
}
for(int i = 2; i <= 1000000; i++)
{
if(!used[i])primes.pb(i);
}
deb((int)primes.size());
*/
int n, q;
cin >> n >> q;
set<pair<int, int> >cntt;
map<int, int>cntt1;
while(q--)
{
char c;
cin >> c;
if(c == 'S')
{
int x;
cin >> x;
if(primes1[x].empty())
{
create(x);
for(auto i: primes1[x])
{
cntt1[i.first]+= i.second;
}
for(auto i: cntt1)
{
cntt.insert({-i.second, i.first});
}
}
else
{
for(auto i: primes1[x])
{
cntt.erase(cntt.find({-cntt1[i.first], i.first}));
cntt1[i.first] -= i.second;
cntt.insert({-cntt1[i.first], i.first});
}
}
}
else
{
int x, y;
cin >> x >> y;
if(x == 1 && y == n)
{
if((*cntt.begin()).first < -1)
{
cout << "DA" << endl;
}
else cout << "NE" << endl;
}
else assert(0);
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
137 ms |
238468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1582 ms |
119488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
137 ms |
238468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |