Submission #330515

# Submission time Handle Problem Language Result Execution time Memory
330515 2020-11-25T15:24:50 Z Cybaen Strange Device (APIO19_strange_device) C++17
0 / 100
1421 ms 524292 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii; 
typedef vector<vi> vvi;  
#define sz(a) int((a).size()) 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>b;i--)
#define endl "\n"
#define fre freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define start ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define N 100002
const ll INF = 1e18+1;
vector<ii> v[N];
unordered_map<ll,ll> mp,mp2;
ll A,B,c;

void mark1(ll n)
{
	for(ll i=n;i<100;i+=c)
	{
		mp[i]=1;
	}

}
void mark2()
{
	ll temp=__detail::__lcm(A,B);
	for(ll i=temp;i<100;i+=temp)
	{
		mp2[i]=1;
	}
}

void solve()
{
int n;
ll ans=0;
ll l,r;
cin>>n>>A>>B;
c=A*B;
bool check=false;

for(ll i=0;i<n;i++)
{
	cin>>l>>r;
	rep(j,0,r-l+1)
	{
	if(mp[l+j]==1 or mp2[l+j]==1)
	{
		if(mp2[l+j]==1 and !check )
		{
			check =true;
			ans++;
		}
		continue;
	}
	else
	{
		ans++;
		mark1(l+j);
	}
}

}
cout<<ans<<endl;

}

int main(){
	start
	solve();
	
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 57 ms 19324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Runtime error 1085 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 182 ms 59520 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 623 ms 119164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 623 ms 119164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 623 ms 119164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2668 KB Output is correct
2 Runtime error 1421 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2668 KB Output is correct
2 Incorrect 57 ms 19324 KB Output isn't correct
3 Halted 0 ms 0 KB -