67ovo

1111

MongoRolls

He_20
HY_39
tyjz_yyds
Kevin12345

zxr123
BT7274
cc_xx
peterHUAN
gebilxs
xm03
mei_24
815741912
I+III

Reckless

67ovo
14小时前
class Solution {
public:
vector<vector<int>> groupThePeople(vector<int>& groupSizes) {
vector<vector<int>>ans;
unordered_map<int,vector<int>>g;
int n=groupSizes.size();

for(int i=0;i<n;i++)
{
g[groupSizes[i]].push_back(i);
}
for(auto& [x,t]:g)
{
int siz=t.size();
int i=0;
while(i!=siz)
{
vector<int>tmp;

for(int j=0;j<x;j++)
{
tmp.push_back(t[i++]);
}
ans.push_back(tmp);
}
}
return ans;
}

};



class Solution {
public:
vector[HTML_REMOVED]> groupThePeople(vector[HTML_REMOVED]& groupSizes) {
vector[HTML_REMOVED]>ans;
map[HTML_REMOVED]>mp;
int n=groupSizes.size();
for(int i=0;i<n;i++)
{
mp[groupSizes[i]].push_back(i);
if(mp[groupSizes[i]].size()==groupSizes[i])
{
ans.push_back(mp[groupSizes[i]]);
mp[groupSizes[i]].clear();
}
}
return ans;
}

};




67ovo
15小时前
#include <iostream>
#include <cstring>
#include <algorithm>
#include<unordered_map>
#include<queue>
using namespace std;

const int N=10;
int dx[]={-1,1,0,0};//上下左右
int dy[]={0,0,-1,1};
string g,seq;
char n;
string endd="12345678x";
int f(string state)
{
int dist=0;
for(int i=0;i<9;i++)
{
if(state[i]!='x')
{
int t=state[i]-'1';
dist+=abs(t/3-i/3)+abs(t%3-i%3);
}
}
return dist;
}
string bfs(string start)
{

priority_queue<pair<int, string>, vector<pair<int, string>>, greater<pair<int, string>>>heap;//优先队列，存到终点的距离
unordered_map<string,int>dist;//起点到此状态的距离
unordered_map<string,pair<string,char>>pre;//存储此状态的上一个状态
char op[]="udlr";
heap.push({f(start),start});
dist[start]=0;

while(heap.size())
{
auto t=heap.top();
heap.pop();
if(t.second==endd)break;
int x,y;
for(int i=0;i<9;i++)
if(t.second[i]=='x')
{
x=i/3,y=i%3;
break;
}

string state=t.second;
string source=state;
for(int i=0;i<4;i++)
{
int nx=x+dx[i],ny=y+dy[i];

if(nx<0||nx>=3||ny<0||ny>=3)continue;

swap(state[nx*3+ny],state[x*3+y]);

if(!dist.count(state)||dist[state]>dist[source]+1)
{
dist[state]=dist[source]+1;
pre[state]={source,op[i]};
heap.push({dist[state]+f(state),state});
}
swap(state[nx*3+ny],state[x*3+y]);
}

}
string res;

while(endd!=start)
{
res+=pre[endd].second;
endd=pre[endd].first;
}
reverse(res.begin(),res.end());
return res;
}
int main()
{
while(cin>>n)
{
g+=n;
if(n!='x')seq+=n;
}
int t = 0;
for (int i=0; i<8;i++ )
for (int j=i+1; j<8;j++)
if (seq[i]>seq[j])
t++ ;
if(t%2)cout<<"unsolvable"<<endl;//A*算法必须保证答案有解
else cout<<bfs(g)<<endl;

return 0;
}



67ovo
1天前
ipython3  # 打python3交互环境

res = 2**112 + 3**78

! echo \$res > ans.txt  # ! 表示后面的内容是shell脚本  ??



67ovo
1天前
tar -zcvf project_a.tar.gz dir_a/*

tar -zxvf project_b.tar.gz


67ovo
1天前
md5sum scores.txt | cut -c 1-32 > ans.txt



67ovo
1天前
head -5 scores.txt > top.txt
tail -4 scores.txt > bottom.txt



67ovo
1天前

cat scores.txt | cut -d ' ' -f 1 | sort > names.txt


67ovo
1天前
cat scores.txt | cut -d ' ' -f 1 > names.txt
cat scores.txt | cut -d ' ' -f 2 > mathematics.txt
cat scores.txt | cut -d ' ' -f 3 > algorithm.txt



67ovo
1天前
find . -name '*.py' | xargs rm


67ovo
1天前
find . -name '*.cpp' | xargs cat | wc -l > ans1.txt

find . -name '*.py' | xargs cat | grep thrift | wc -l > ans2.txt