最简洁的代码,没有之一!

P3613 【深基15.例2】寄包柜

wangzhih @ 2022-01-01 20:49:28

STL大法好

#include<bits/stdc++.h>
using namespace std;
int n,q,oper,i,j,k;//oper操作符 
map<int,map<int,int> > a;//"> >"用于防止误判位操作 
int main() {
    cin>>n>>q;
    while(q--){//重复q次 
        cin>>oper>>i>>j;
        if(oper-1) cout<<a[i][j]<<endl;//读 
        else cin>>k,a[i][j]=k;//存
    }
    return 0;
}

by Isshiki·Iroha @ 2022-01-01 20:51:13

%%%%%%


by AlbrecRoon @ 2022-01-01 20:51:44

orz


by Ew_Cors @ 2022-01-01 20:52:17

stOstOstO @wangzhih OrzOrzOrz


by Isshiki·Iroha @ 2022-01-01 20:55:49

@AlbrecRoon
@Ew_Cors

他高斯消元法一遍过


by Phartial @ 2022-01-01 20:57:14

#include<bits/stdc++.h>
using namespace std;int n,q,o,i,j;map<int,map<int,int>>a;main(){cin>>n>>q;while(q--)cin>>o>>i>>j,o-1?(cout<<a[i][j]<<endl,0):(cin>>a[i][j],0);}

年轻人不要太气盛


by Ew_Cors @ 2022-01-01 20:57:20

@Isshiki·Iroha 那更要膜拜%%%Orz


by Phartial @ 2022-01-01 20:57:49

话说还能更短吗


by Ew_Cors @ 2022-01-01 20:58:36

@wsfxk

o-1?(cout<<a[i][j]<<endl,0):(cin>>a[i][j],0);}

这个 ,0 删去应该没什么问题罢。。


by Phartial @ 2022-01-01 20:59:18

@Ew_Cors 不行啊,删了两边类型就不一致了


by Ew_Cors @ 2022-01-01 21:00:17

@wsfxk az

一定要类型一致么?


| 下一页