-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10474 - Where is the Marble.cpp
111 lines (86 loc) · 2.52 KB
/
10474 - Where is the Marble.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include<bits/stdc++.h>
using namespace std;
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define sf scanf
#define pf printf
#define pcs(x,y) printf("Case %d: %s", x, y)
#define pci(x,y) printf("Case %d: %d", x, y)
#define pcl(x,y) printf("Case %d: %lld", x, y)
#define NL printf("\n")
#define nl '\n'
#define mod 1000000007
#define FI freopen("in.txt","r",stdin)
#define FO freopen("out.txt","w",stdout)
#define FOR(i,j,k) for(int i = j; i < k; i++)
#define rep(l,n) FOR(l,0,n)
#define per(i,j,k) for(int i = j; i > k; i--)
#define PI acos(-1.0)
#define eps 1e-7
#define pb(x) push_back(x)
#define ppb() pop_back()
#define sz(x) x.size()
#define xx first
#define yy second
#define mp(a,b) make_pair(a,b)
#define ssz(a) strlen(a)
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define clr(ara) mem(ara,0)
#define st(ara) mem(ara,-1)
#define all(a) a.begin(),a.end()
//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#define debug(args...) {dbg,args; cout<<endl;}
struct debugger{
template<typename T> debugger& operator , (const T& v){
cout<<v<<" ";
return *this;
}
}dbg;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef vector< PII > VII;
int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
///=>=>=>=>=>=>=>=>=>00100<=<=<=<=<=<=<=<=<=///
VI v;
int bs(int n, int m){
int l = 0, r = n, mid, ret = -1;
while(l < r){
mid = (l + r) / 2;
if(v[mid] >= m) r = mid;
else l = mid + 1;
}
return (v[r] == m) ? r : -1;
}
int main(){
//std::ios_base::sync_with_stdio(0);//cin.tie(0);
//FI;//FO;
int t = 0, z = 0, len;
int n = 0, k = 0, m = 0; int ans = 0;
while(sii(n,k) and n and k){
v.clear();
rep(l,n){
si(t);
v.pb(t);
}
pf("CASE# %d:\n", ++z);
sort(all(v));
while(k--){
si(m);
ans = bs(n,m);
if(ans == -1) pf("%d not found\n", m);
else pf("%d found at %d\n", m, ans+1);
}
}
return 0;
}