Submission #1688438
Source Code Expand
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};
#define p_queue(i) priority_queue<i>
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>>
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a)
#define vlb(a,k) (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}
//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}
//ll nHr(int n,int r){ret nCr(n+r-1,r);}
///////////////////////////////////////////////////////////////////////////
set<ll> s;
ll func(ll m,ll n){
ll a = m,b = n-m;
/*ll a = n/2,b = n-a;
if(n%2== 0){
a--;
b++;
}*/
if(a >= b){
if(s.count(n) == 0){
s.it(n);
ret 1;
}else ret 0;
}else if(s.count(a) == 0 && s.count(b) == 0){
s.it(a);
if(func(a+1,b) == 1){
return 1;
}else{
s.erase(a);
func(a+2,b-1);
}
}
ret 0;
}
int main(){
ll n;
cin >> n;
func(1,n);
ll sum = 0;
for(auto ite:s){
P(ite);
sum += ite;
}
//P(sum);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Exactly N points |
User |
hirata0517masato |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2771 Byte |
Status |
WA |
Exec Time |
9 ms |
Memory |
640 KB |
Judge Result
Set Name |
sample |
dataset1 |
dataset2 |
Score / Max Score |
0 / 0 |
0 / 200 |
0 / 100 |
Status |
|
|
|
Set Name |
Test Cases |
sample |
sample-01.txt, sample-02.txt, sample-03.txt |
dataset1 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
1 ms |
256 KB |
01-02.txt |
AC |
1 ms |
256 KB |
01-03.txt |
WA |
1 ms |
256 KB |
01-04.txt |
WA |
1 ms |
256 KB |
01-05.txt |
WA |
1 ms |
256 KB |
01-06.txt |
WA |
1 ms |
256 KB |
01-07.txt |
AC |
1 ms |
256 KB |
01-08.txt |
WA |
1 ms |
256 KB |
01-09.txt |
AC |
1 ms |
256 KB |
01-10.txt |
WA |
1 ms |
256 KB |
02-01.txt |
WA |
9 ms |
640 KB |
02-02.txt |
AC |
9 ms |
640 KB |
02-03.txt |
AC |
9 ms |
640 KB |
02-04.txt |
WA |
9 ms |
640 KB |
02-05.txt |
WA |
9 ms |
640 KB |
02-06.txt |
WA |
5 ms |
512 KB |
02-07.txt |
WA |
4 ms |
384 KB |
02-08.txt |
WA |
9 ms |
640 KB |
sample-01.txt |
AC |
1 ms |
256 KB |
sample-02.txt |
AC |
1 ms |
256 KB |
sample-03.txt |
AC |
1 ms |
256 KB |