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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
| set占用内存很大,尽量不使用
map<pair<int,int>,int>s; s[{1,1}]=1; map<array<int,2>,int>ss; ss[{1,1}]=1; ss.erase({1,1}); ss.count({1,1}); for(auto k : ss) { int x=k.first[0]; int y=k.second; cout<<x<<" "<<y; }
vector<map<double,vector<int>>> q(n); q[1][1].push_back(0); map<long long,map<long long,int> > mp; mp[1][1]=1;
vector<vector<int>> a(n, vector<int>(m)); vector<vector<vector<int>>> d(n,vector<vector<int>>(m)); vector< vector < vector<int> > > b(n,vector<vector<int>>(m,vector<int>(k,1))); sort(d[i][j].begin(),d[i][j].end()); d[i][j].erase(unique(d[i][j].begin(),d[i][j].end()),d[i][j].end());
vector<int>v; auto dfs=[&](int x){ }; auto func = [] () { cout << "Hello world"; }; func(); auto st=[](int x)->bool{ }; sort(v.begin(),v.end(),[](int x,int y){ return x>y; });
getline(cin,s); memset(a,0,sizeof(a)); memcpy(b,a,sizeof(a)); pow (a,b); ceil(x)、floor(x)、round(x) log(x)、log2(x)、loga(x) abs(x),fabs(x) string s=to_string((int)s) stable_sort()、sort() vector<array<int,3>>s; s.push_back({1,2,3}); for(auto k :s) {int a=x[0],b=x[1],c=x[2];}
sort(a+1,a+10,[](int z,int y){ return z>y; }); auto check=[&](int x) ->bool{ if(x>1) return 1; return 0; };
vector大法 vector<int> v1; vector<int> v2(5);
vector<int> v3(5, 1); vector<int> v4 = {4, 5, 6, 7}; cout << v[2] << endl; v.push_back(3); v.pop_back(); cout << v.size() << endl; v.clear(); v.empty() v.front() = 1; v.back() = 2; vector<vector<int>>s(n,vector<int>(m)); v2.swap(v1); sort(v.begin(),v.end()); vector<int>w; w.emplace_back(1); w.insert(w.begin(),10); w.insert(w.begin(),3,10);
find string st="1234";
st.find("192",1) if(st.find("192")==string::npos ) cout<<"NO"; else cout<<"YES"; string s=st.substr(2); string s=st.substr(2,3);
string s = "abcdef";
s.replace(3, 2, "123456");
s.replace(3, 2, "123456", 2, 3);
s.replace(3, 1, 5, '#'); cout << s << endl;
int main() { string str = "what are you doing now", sub; stringstream ss1(str); while (ss1 >> sub) { cout << sub << endl; }
str = "123 45.6"; stringstream ss2; ss2 << str; int x; double y; ss2 >> x >> y; cout << x << ' ' << y; return 0; } stack<int>st;
queue<int> front函数和back函数 priority_queue<int, vector<int>, greater<int> > heap1; priority_queue<int, vector<int>, less<int> > heap2;
struct pii { int x;
bool operator< (const pii& j) const { if (this->x > j.x) return true; return false; } }; priority_queue<pii> heap;
set<int> ass = {3, 4, 3, 2, 5}; ass.insert(1); if (ass.insert(3).second == false) { cout << "插入失败,set里面有这个元素了" << endl; } ass.find(j)!=ass.end() 说明找到 否则没有 auto it=sc.lower_bound(k); if(it!=sc.end()) { sc.erase(it); sc.insert(k); }
if(ass.count(1))cout<<"YES"; ass.erase(3);
bitset<>
bitset<10> b1;
bitset<10> b2(20); cout << b2 << endl;
bitset<10> b3("1010"); cout << b3 << endl;
int arr[3] = {1, 2, 3}; do { for (int i = 0; i < 3; ++i) { cout << arr[i]; } cout << endl; } while (next_permutation(arr, arr + 3));
multiset<int>s; multiset<int,greater<int>>s; s.count(1); s.insert(1); s.erase(s.find(a)); *s.rbegin(); *s.begin();
struct cmp{ bool operator() (const int &a,const int &b){ return a>b; } }; void solve() {set<int>s;
set<int,cmp>w; set<int,greater<int>> setb; auto it=s.find(x); if(it!=s.end()) { } int ik=s.count(x); s.begin(); s.end(); *(--w.end())==*w.rbegin() s.clear(); s.size(); s.insert(10); s.erase(100); cout<<s.count(x); cout << "第一个大于或等于3的元素: " << *s.lower_bound(3) << endl; cout << "第一个大于2的元素: " <<*s.upper_bound(2) << endl; }
map map<int, vector<int>> pos;
map<int,int>s; for(auto it : s){ int z=it.first; int y=it.second;}
|